Repository navigation
Bracket matching motion with % - #254
Conversation
Now just press % to go to the matching bracket. Conflicts: lib/motions/search-motion.coffee
instead of just the start locations, to be able to compare the ranges for bracker matching
|
Can you rebase this or merge master into your branch? |
…motion-pr Conflicts: keymaps/vim-mode.cson lib/motions/search-motion.coffee
|
@bhuga I've merged master into my branch. Also added specs for the motion. |
There was a problem hiding this comment.
This block is pretty wordy. What about something like this pseudocode:
switch @character
when ']' then '['
when '[' then ']'
...
else ''
@reverse = true if _.contains(['(', '[', '{')], @character)
|
I've really been wanting this! Just one nitpick in the code. I am seeing an off-by-one error, though. n the text string The tests pass and look fine to me, so I'm not sure why it's different. |
|
Yes. I just realized that in vim if you have My use case is stand on the opening and hit % or d% to cut or something. I'll try to add this to the PR. |
Now you can press % inside (abc) and it will do the same as in vim.
Now there are tests of when it finds the nearest symbol to match. For examples (abcd) and you hit % while on b.
|
@bhuga I've commited some changes. Should work now. Hitting % with |
There was a problem hiding this comment.
easy one liner: cur = if @startUp then @startUpPos else @editor.getCursorBufferPosition()
|
Unfortunately I'm still getting some errors 😦: For
I think there is some state getting leaked between multiple presses. While trying to make this list, I think some cases did not repeat every time. |
|
@bhuga I can't seem to reproduce any of those. In the example I want to fix the last one, but I want to make sure we're seeing the same behavior first. |
|
How embarrassing, I had a user keymap for This code is kind of weird, but then again, so is vim's behavior. Great work. |
…ion-pr Bracket matching motion with %
% in command mode will move to the matching bracket, right now as proof of concept ( [ { with ) ] }.
works correctly with d% or y%, as expected.