-
Notifications
You must be signed in to change notification settings - Fork 7
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
Unbalanced parens make SidewaysArgumentTextobjI/A jump to unrelated line #24
Comments
There's some interesting layers to the problem here. In general, the plugin couldn't handle unbalanced brackets. It expects that an expression is valid, because I honestly don't know how I'd handle the logic for it otherwise :). That said, the problem here is that the bracket is in a string, and that should be ignored by default. The thing is, I ignore particular syntax groups for ruby ( sideways.vim/plugin/sideways.vim Line 39 in 01a96f7
So, first off, I fixed a few places that weren't correctly skipping syntax patterns. I also added some default behaviour to try to ignore all "Comment" and "String" patterns, with a setting to escape it if it's necessary. The relevant docs are here:
Long story short, the example you showed should work as expected now, but you should consider the relevant documentation in case you run into similar issues that I haven't thought of. Does this seem to solve the problem? |
I can confirm that updating to 6703dae fixes my C# example above. Thanks so much! However, I experience some similar jumping to far away text (also C#):
And
The Alternatively, minor modifications cause the comment to be selected instead of
Removing the first string and the comment makes it behave as expected. Possibly this is related to your changes. On 2d5cd2b, the comment is selected instead of |
Hm, something to do with the string matching, I think. I've adjusted one of the search patterns, and it seems to work now, for this example.
This one is going to be trickier. I'll need some time to think it over. Comments are ignored mostly to avoid code that's competely commented out. A line-based comment in an argument list is something I hadn't considered. |
On 01bcf0f, sideways is better behaved but not correct on my example (copypasted to new cs file). It selects the comment instead of jumps_to_here. If sideways uses syntax then you should know I'm using omnisharp vim to improve vim's C# syntax. |
Improves my pathological case: AndrewRadev/sideways.vim#24 (comment) Changelog: Try to fix matching empty quotes Fix text object, wrong column used
Several times I've had sideways select text that doesn't include my cursor position. I think it would make more sense to do nothing than jump to another part of the buffer. I've found a reliable and small repro case:
Do:
(
i,
isSidewaysArgumentTextobjI
)Result:
The SerializedProperty line is selected.
va,
selects the S in SerializedProperty and the space before it.The only case I can think of where sideways selects something that doesn't include my cursor position is on a comma and the next argument is on the following line (but I'd argue it should select the preceeding argument). Would it make sense to limit the textobjs to require inclusion of the cursor position?
Using 2d5cd2b on Gvim 8.0.596 Win64
The text was updated successfully, but these errors were encountered: