t9md / atom-vim-mode-plus

vim-mode improved
https://atom.io/packages/vim-mode-plus
MIT License
1.4k stars 112 forks source link

use buffer.onDidChangeText() #941

Closed t9md closed 7 years ago

t9md commented 7 years ago

Fix #939

@maxbrunsfeld

Hi, Thanks for notifying me for upcoming changes. And onDidChangeText was worked for my purpose. Anyway, I want to share vim-mode-plus(vmp)'s usage of onDidChange, since this is very critical for vmp's feature which I think very important among many features of vmp.

Different from the code you pointed out in issue comment, following code is actually affected by this change.(maybe because your regex didn't match getBuffer().onDidChange).

https://github.com/t9md/atom-vim-mode-plus/blob/74d3b350bfd57fa3bd0c52742c0ef2b12106cf11/lib/misc-command.js#L59-L65

vim-mode-plus really depending on buffer.onDidChange event to flash changed(add/delete) text range on undo or redo operation. That's gives enough context for developers.

And vmp support occurrence, it change/delete multiple selection in single transaction.

changes-hl

So summarized range info is not enough, granular information for each changes are crucial for precise highlight. Fortunately onDidChangeText provides this granular information with {changes} props. And as far as I checked, v1.19.7 works with onDidChangeText()

So I did just replaced old onDidChange event.