Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ichizok
Copy link
Contributor

@ichizok ichizok commented Dec 12, 2017

Problem summary

Under the following conditions, Vim does not update the cells of unicode ambiguous-width character properly.

  • On a terminal which treats ambiguous-width as 1 cell
  • :set ambiwidth=double

Repro steps

Create 1.txt and 2.txt

vim --clean

:e 1.txt
:normal! izzzzzz
:w
:e 2.txt
:exe "normal!" "iab\u03bbef"
:wq
  • \u03bb is λ (lambda)

1.txt:
1 txt

2.txt: (ambw=double)
2 txt

Open 1.txt and 2.txt

vim --clean +'set ambw=double'

:e 1.txt
:e 2.txt

Result

1to2

z of 1.txt remains just behind lambda of 2.txt.

Details

When drawing a content of 2.txt, Vim outputs into terminal:

>>>   CSI 1;1H                CUP / move cursor to (row=1, col=1)
>>>  abλ
>>>   CSI 1;5H                CUP / move cursor to (row=1, col=5)
>>>  ef

Vim treats lambda as 2 cells but terminal treats it as 1 cell, so (row=1, col=4) cell is not updated.

Solution

  • Overwrite the cells by 2-spaces before output ambiguous-width (when ambw=double)

@codecov-io
Copy link

Codecov Report

Merging #2436 into master will increase coverage by 0.02%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2436      +/-   ##
==========================================
+ Coverage   74.51%   74.54%   +0.02%     
==========================================
  Files          92       92              
  Lines      132721   132726       +5     
  Branches    29112    29113       +1     
==========================================
+ Hits        98903    98940      +37     
- Misses      33783    33786       +3     
+ Partials       35        0      -35
Impacted Files Coverage Δ
src/screen.c 73.87% <66.66%> (-0.03%) ⬇️
src/os_unix.c 54.23% <0%> (-0.14%) ⬇️
src/message.c 68.67% <0%> (-0.05%) ⬇️
src/channel.c 82.72% <0%> (-0.05%) ⬇️
src/window.c 81.77% <0%> (+0.03%) ⬆️
src/gui.c 47.5% <0%> (+0.05%) ⬆️
src/if_py_both.h 76.59% <0%> (+0.14%) ⬆️
src/if_xcmdsrv.c 84.71% <0%> (+0.17%) ⬆️
src/gui_beval.c 62.66% <0%> (+0.42%) ⬆️
src/libvterm/src/screen.c 53.34% <0%> (+6.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a703aae...a179328. Read the comment docs.

@brammool brammool closed this in fae8ed1 Dec 12, 2017
@ichizok ichizok deleted the fix/redraw-ambiguous-width branch December 13, 2017 03:13
adizero pushed a commit to adizero/vim that referenced this pull request May 19, 2018
Problem:    Char not overwritten with ambiguous width char, if the ambiguous
            char is single width but we reserve double-width space.
Solution:   First clear the screen cells. (Ozaki Kiichi, closes vim#2436)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants