Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set ambiwidth=double will cause display error #19191

Closed
Alaskra opened this issue Jul 1, 2022 · 3 comments · Fixed by #19686
Closed

set ambiwidth=double will cause display error #19191

Alaskra opened this issue Jul 1, 2022 · 3 comments · Fixed by #19686
Labels
bug issues reporting wrong behavior display redraw, layout, presentation tui unicode 💩 (multibyte) unicode characters

Comments

@Alaskra
Copy link

Alaskra commented Jul 1, 2022

Neovim version (nvim -v)

NVIM v0.7.0 Build type: Release

Vim (not Nvim) behaves the same?

no, vim8.2

Operating system/version

manjaro

Terminal name/version

terminator

$TERM environment variable

xterm-256color

Installation

AUR

How to reproduce the issue

  1. nvim --clean
  2. paste this line: 因此如果您在网页版的坚果云发现同一个目录下有两个名称为“Nutstore”和“nutstore”(小写的“n”)的文件/文件夹,在Windows/Mac系统上其中一个文件/文件夹后面会加上“大小写冲突”的字样
  3. :set ambiwidth=double
  4. mouse drag to change terminal window width, you will see the symbol > which break a line misdisplay.
    Peek 2022-07-01 21-52

Expected behavior

there won't any character in the right of the symbol >.

Actual behavior

there are some character in the right of the symbol >.

@Alaskra Alaskra added the bug issues reporting wrong behavior label Jul 1, 2022
@justinmk justinmk added encoding display redraw, layout, presentation unicode 💩 (multibyte) unicode characters labels Jul 1, 2022
@zeertzjq zeertzjq added tui and removed encoding labels Jul 1, 2022
@zeertzjq
Copy link
Member

zeertzjq commented Jul 1, 2022

Related: #15898

@zeertzjq zeertzjq added complexity:high High-risk, potential for delicate/cascading effects and removed complexity:high High-risk, potential for delicate/cascading effects labels Jul 1, 2022
@zeertzjq
Copy link
Member

zeertzjq commented Aug 8, 2022

This small change may "fix" the problem:

diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index e2289eb9c..78281470d 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -788,6 +788,7 @@ static void cursor_goto(UI *ui, int row, int col)
 {
   TUIData *data = ui->data;
   UGrid *grid = &data->grid;
+  goto safe_move;
   if (row == grid->row && col == grid->col) {
     return;
   }

But this "fix" just disables a bunch of performance improvements.

@zeertzjq
Copy link
Member

zeertzjq commented Aug 8, 2022

A less drastic solution is to only force repositioning cursor after printing an ambiguous width character:

diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index e2289eb9c..2490104b6 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -748,6 +748,9 @@ static void print_cell(UI *ui, UCell *ptr)
   update_attrs(ui, ptr->attr);
   out(ui, ptr->data, strlen(ptr->data));
   grid->col++;
+  if (utf_ambiguous_width(utf_ptr2char(ptr->data))) {
+    grid->row = -1;
+  }
   if (data->immediate_wrap_after_last_column) {
     // Printing at the right margin immediately advances the cursor.
     final_column_wrap(ui);
@@ -1439,6 +1442,9 @@ static void tui_raw_line(UI *ui, Integer g, Integer linerow, Integer startcol, I
     grid->cells[linerow][c].attr = attrs[c - startcol];
   }
   UGRID_FOREACH_CELL(grid, (int)linerow, (int)startcol, (int)endcol, {
+    if (cell->data[0] == NUL && grid->row == -1) {
+      continue;
+    }
     cursor_goto(ui, (int)linerow, curcol);
     print_cell(ui, cell);
   });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior display redraw, layout, presentation tui unicode 💩 (multibyte) unicode characters
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants