From 16ce2e006bb4c83e9054cdbfe780ff25fc757fc2 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Fri, 4 May 2018 16:34:46 +0200 Subject: [PATCH 1/2] screen: avoid artifacts Put back the condition that was accidentally removed in https://github.com/neovim/neovim/commit/d42f934bcb3e9e876e5e7ba0ab5cd824175fd10c - if (enc_utf8 && ScreenLinesUC[off] != 0) - bytes[utfc_char2bytes(off, bytes)] = NUL; - else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e) { - bytes[0] = ScreenLines[off]; - bytes[1] = ScreenLines2[off]; - bytes[2] = NUL; - } else if (enc_dbcs && MB_BYTE2LEN(bytes[0]) > 1) { - bytes[1] = ScreenLines[off + 1]; - bytes[2] = NUL; - } + bytes[utfc_char2bytes(off, bytes)] = NUL; Fixes #8357 --- src/nvim/screen.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 2e64eb864f..0dd26fab76 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5307,7 +5307,9 @@ void screen_getbytes(int row, int col, char_u *bytes, int *attrp) bytes[0] = ScreenLines[off]; bytes[1] = NUL; - bytes[utfc_char2bytes(off, bytes)] = NUL; + if (ScreenLinesUC[off] != 0) { + bytes[utfc_char2bytes(off, bytes)] = NUL; + } } } From ec1a7791b00f98460c60e7ae4eec383dce741de8 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Fri, 4 May 2018 19:10:45 +0200 Subject: [PATCH 2/2] test: screen artifacts --- test/functional/ui/screen_basic_spec.lua | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 7fafd6b352..478f703da9 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -645,4 +645,43 @@ describe('Screen', function() ]]) end) end) + + -- Regression test for #8357 + it('does not have artifacts after temporary chars in insert mode', function() + command('inoremap jk ') + feed('ifooj') + screen:expect([[ + foo^j | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {2:-- INSERT --} | + ]]) + feed('k') + screen:expect([[ + fo^o | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) end)