-
Notifications
You must be signed in to change notification settings - Fork 90
split ruby blocks correctly when ; is inside string literal #199
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6e2756a
split ruby blocks correctly when ; is inside string literal
rrhubenov 6bd9fcc
tests for the 3 types of ruby string literals
rrhubenov 2949ec6
replace body and loop over ';' skipping rubyString syntax group
rrhubenov 6509663
don't wrap around buffer when searching replacement
rrhubenov 64b9774
remove unnecessary search
rrhubenov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndrewRadev
I implemented the second method you described.
But since search(replacement, 'cW') jumps one line above the body of the "do; end" block, I had to
use "normal! j0" to move to the beginning of the correct line.
It seems to me that moving 1 line lower is kind of dirty, but I'm not sure.
I could use sj#GetMotion('Vi{') but I suspect there might be a cleaner way.
Do you have any suggestions :)?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem in
j0, you'll see me do this kind of thing elsewhere as well :). Nothing dirty about using the basic motions.A practical problem, though, is searching for the replacement. What if the replacement has special characters, like
*? You can try it withfoo * bar, which as a pattern is "foo, followed by spaces, followed by bar", which won't actually match the string :). It's possible to search for a literal string by prefixing it with\V, but it feels unnecessary. Why the search? Where are you trying to position the cursor? Wouldn't justj0be enough to get you in the right place? At least when I'm testing the code out, it seems like removing the search still works fine. Tests are passing too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, great!
I wasn't sure where ReplaceMotion would leave the cursor.
I've left only j0. Less code, less bugs :)