From c128db95440cc4caf34cbad5e91e1e26bb5fa6a3 Mon Sep 17 00:00:00 2001 From: Glauber Campinho Date: Fri, 1 Sep 2017 15:12:48 +0200 Subject: Fix del_chars not considering wide chars and update buffer length before calling write_buf After deleting the chars the function `del_chars` was considering the code points to move the cursor back and not the graphemes --- erts/emulator/drivers/unix/ttsl_drv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'erts/emulator/drivers') diff --git a/erts/emulator/drivers/unix/ttsl_drv.c b/erts/emulator/drivers/unix/ttsl_drv.c index 3d007173c4..2a508b02eb 100644 --- a/erts/emulator/drivers/unix/ttsl_drv.c +++ b/erts/emulator/drivers/unix/ttsl_drv.c @@ -936,10 +936,10 @@ static int put_chars(byte *s, int l) int n; n = insert_buf(s, l); + if (lpos > llen) + llen = lpos; if (n > 0) write_buf(lbuf + lpos - n, n); - if (lpos > llen) - llen = lpos; return TRUE; } @@ -1016,7 +1016,7 @@ static int del_chars(int n) outc(' '); move_left(1); } - move_cursor(llen + l, lpos); + move_cursor(llen + gcs, lpos); } else if (pos < lpos) { l = lpos - pos; /* Buffer characters */ @@ -1036,7 +1036,7 @@ static int del_chars(int n) outc(' '); move_left(1); } - move_cursor(llen + l, lpos); + move_cursor(llen + gcs, lpos); } return TRUE; } @@ -1289,7 +1289,7 @@ static int cp_pos_to_col(int cp_pos) if (cp_pos > llen) { col += cp_pos - llen; - cp_pos = llen; + cp_pos = llen; } while (i < cp_pos) { -- cgit v1.2.3