-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autoindent during typing un-indents "fi" too far #15
Comments
ah, sounds reasonable. Can you please create a PR? I'll try to come up with a test case then. Thanks! |
aswild
added a commit
to aswild/vim-sh-indent
that referenced
this issue
Apr 27, 2019
Regression from ef2e050 "Better indenting for nested if sections" which changed to using searchpair() instead of search(). When typing "fi", the cursor is after the start of the \<fi\> match, so vim un-indents back to the next outer if/fi block rather than the expected block. The help for searchpair() suggests "When searching backwards and {end} is more than one character, it may be useful to put "\zs" at the end of the pattern, so that when the cursor is inside a match with the end it finds the matching start." Follow this suggestion to restore the expected behavior. Fixes: chrisbra#15
PR is up. I'm not sure how to write a test case for insert-mode stuff |
aswild
added a commit
to aswild/linuxfiles
that referenced
this issue
Jul 1, 2019
merged upstream chrisbra/vim-sh-indent#15
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regression from ef2e050 which changed to using the
searchpair
function.This seems to happen whenever I type
fi
to end an if statement that's indented.When I type the
fi
on line 5, it's un-indented back to column 1 (matching theif
on line 1) rather than to column 5 (matching the if on line 3).When typing the
fi
on line 5, the cursor is in the column with thei
character and the backwardssearchpair
finds theif
on line 1 rather than line 3. This is because since the cursor is after thefi
, it's found and assumed to be a nested if/fi pair.The
searchpair
documentation suggests When searching backwards and {end} is more than one character, it may be useful to put "\zs" at the end of the pattern...In my tests, it looks like this works, though I'm not totally clear what the
\zs
does. Somehow it's moving where the start of the pattern is so that the searchpair is able to consider the fi right before cursor not included in the first match.Here's a patch which I believe fixes the issue.
The text was updated successfully, but these errors were encountered: