From 0d9806d73afc0d489714c8c3b324b8b227e5c000 Mon Sep 17 00:00:00 2001 From: Hyeon Kim Date: Mon, 15 Dec 2014 06:29:40 +0900 Subject: [PATCH] Neovim support: line buffers shouldn't contain newlines The result of `difflib.unified_diff()` may contains newlines at the end of its each line. It's suppressed in original Vim, but it's illegal in Neovim. Since there is no good way to prevent `difflib` from appending newlines to the results, `_output_preview_text()` function should sanitize it. Thanks @michamos Reference: https://github.com/neovim/neovim/blob/a5edc5f2572d6d63f7f7a32ae6ec7bcabe1472b6/src/nvim/api/buffer.c#L215 https://github.com/sjl/gundo.vim/pull/30#issuecomment-170064637 --- autoload/gundo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/gundo.py b/autoload/gundo.py index e80dcda..bc88f6b 100644 --- a/autoload/gundo.py +++ b/autoload/gundo.py @@ -336,7 +336,7 @@ def _fmt_time(t): def _output_preview_text(lines): _goto_window_for_buffer_name('__Gundo_Preview__') vim.command('setlocal modifiable') - vim.current.buffer[:] = lines + vim.current.buffer[:] = [line.rstrip('\n') for line in lines] vim.command('setlocal nomodifiable') def _generate_preview_diff(current, node_before, node_after):