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

Skip to content

Conversation

@simnalamburt
Copy link
Contributor

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.

Reference

@evantravers
Copy link

👍

@simnalamburt
Copy link
Contributor Author

@evantravers. @sjl looks tired (he hasn't checked this PR over 45 days) so I forked this. vim-mundo supports nvim and it merged some reasonable pull requests which made to this repo. Please take a look! :D

@tiagoboldt
Copy link

this is still an issue. @sjl are you still maintaining the plugin?

@eyalfir
Copy link

eyalfir commented Dec 6, 2015

👍

@sjl
Copy link
Owner

sjl commented Dec 7, 2015

This strips more than just newlines. Does it break the diffs if lines contain trailing spaces?

@michamos
Copy link

michamos commented Jan 8, 2016

Adding '\n' as argument to rstrip works and only strips newlines:

diff --git a/autoload/gundo.py b/autoload/gundo.py
index 281b30c..a61ec20 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):

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
  sjl/gundo.vim#30 (comment)
@simnalamburt
Copy link
Contributor Author

@michamos Thanks
@sjl Fixed it!

sjl added a commit that referenced this pull request Jan 19, 2016
Neovim support: line buffers shouldn't contain newlines
@sjl sjl merged commit 8b63b05 into sjl:master Jan 19, 2016
@sjl
Copy link
Owner

sjl commented Jan 19, 2016

Merged, thanks.

@simnalamburt simnalamburt deleted the nvim-support branch January 20, 2016 16:07
dsummersl pushed a commit to dsummersl/gundo.vim that referenced this pull request Nov 27, 2016
dsummersl added a commit to dsummersl/gundo.vim that referenced this pull request Nov 27, 2016
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.

6 participants