cohama / lexima.vim

Auto close parentheses and repeat by dot dot dot...
996 stars 46 forks source link

Characters after cursor deleted in error in a C style function scope due to bad rule #26

Closed raymond-w-ko closed 8 years ago

raymond-w-ko commented 8 years ago

For example, if you have:

function dummy() {
(asd|)
}

and you press <BS> once the right paren ')' get deleted when it is not suppose to. The cause is the bad rule below which is causing overmatching. Escaping the [] characters fixes it. Please check.

diff --git a/autoload/lexima.vim b/autoload/lexima.vim
index 82bff0f..f41e8e6 100644
--- a/autoload/lexima.vim
+++ b/autoload/lexima.vim
@@ -84,7 +84,7 @@ let g:lexima#space_rules = [
 \ {'char': '<Space>', 'at': '{\%#}', 'input_after': '<Space>'},
 \ {'char': '<BS>', 'at': '{ \%# }', 'delete': 1},
 \ {'char': '<Space>', 'at': '\[\%#\]', 'input_after': '<Space>'},
-\ {'char': '<BS>', 'at': '[ \%# ]', 'delete': 1},
+\ {'char': '<BS>', 'at': '\[ \%# \]', 'delete': 1},
 \ ]
szw commented 8 years ago

The same happens with " characters. Actually your fix seems to solve all troubles. :+1:. I'd suggest to create a quick pull request with the fix @raymond-w-ko!

cohama commented 8 years ago

Thank you for reporting this issue. I have fixed. Actually, escaping ] is unnecessary when [ has already espaced.

The same happens with " characters.

I tried " case but nothing happened. Could you please tell me what the problem is

szw commented 8 years ago

Ok, here's explanation: https://asciinema.org/a/7yaq47mccv1dpv3r72ybyo5mx