Comments (4)
Both problems are working as expected. There is currently no support for handling strings in arguments. To targets.vim it looks like this:
line | function(a, 33, Rstyle="calls, with commas inside strings, are OK")
separators | ( , , , , )
arguments | 1 222 33333333333333 444444444444444444444444444 55555555
I implemented support for nested blocks and such because it is straight forward to match them. When I see an opening (
I know that I should look for the closing one on the right. Implementing the same for quotes is more complicated because I don't know where a quote starts and ends. In our example there are two possible interpretations (depending on context):
line | function(a, 33, Rstyle="calls, with commas inside strings, are OK")
quotes | " "
contents A | 22222222222222222222222222222222222222222
contents B | 11111111111111111111111 3
It might seem natural that A
is the better fit in this case, but how would you express that?
One approach I've chose for quote text objects could be applied here as well: If there's an even number of quote characters on the line, assume that the first one begins a quote. That would work in this example. But how do we deal with cases where there's an odd number of quotes in the line?
I'd like to avoid being dependent on filetype specifics. If you can help me come up with a solid set of rules I might consider implementing something like this. Otherwise I'd rather keep it simple by not supporting it at all.
By the way, I see that this is an example line. Did you open this issue because you were curious if it works, or do you actually have real world use cases where this would be needed? Because, again, I'd rather keep it simple until features are actually needed.
Oh and lastly, I just tried to reproduce your final result with the cursor in the first column. I tried with your exact Vim version 7.4.273, but it always worked as expected: When trying to select an invalid target I hear a beep while the last visual selection remains unaffected. What version of targets.vim are you using?
from targets.vim.
I tried with your exact Vim version 7.4.273, but it always worked as expected
Fixed by your 567a293 commit.
By the way, I see that this is an example line. Did you open this issue because you were curious if it works, or do you actually have real world use cases where this would be needed?
It does occur now and then: Logger(WARN, "Error: received X, expected Y")
But how do we deal with cases where there's an odd number of quotes in the line?
First, is there a real-world case of arguments with an odd number of quotes where the odd-quote-out isn't preceded by a backslash?
from targets.vim.
I see, I will consider handling quotes for argument text objects 👍
from targets.vim.
The way to deal with this is should probably be to leverage syntax highlighting state as a hint... Also the (pretty old) argtextobj vim plugin handles this case correctly, but where it falls down (and targets.vim is better at) is with argument lists that span multiple lines.
So maybe you can ape what argtextobj did to detect quotes.
from targets.vim.
Related Issues (20)
- [Bug Report] Why does targets.vim reset my filetype?
- targets.vim causing issue with macros HOT 6
- cin' not working with \
- Disabling mappings still causes health check warnings.
- Define argument source with longer separator (multiple characters). HOT 2
- cin" doesn't target next quotes properly HOT 2
- `ia` doesn't handle nested braces when arguments are put each on it's own line HOT 4
- Square brackets argument doesn't work HOT 1
- Supporting Other Plugins HOT 1
- Unable to select pair text object with other pair on the same line HOT 1
- Stops working with "set nomagic"
- dot-repeat echoes sometimes ':call targets#do()'
- README.md has Pathogen example that uses "git://" URL instead of "https://" or "ssh://" URL
- ci( doesn't seek forward
- repeat motion in visual mode does not extend selection
- Missing mapping for r
- How to install for Intellij's ideavim HOT 1
- Mess up with di"
- [feature-request] make it possible to disable one or more omap/vmap ?
- ia do not detect outer scope when an inner scope is present in the line
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from targets.vim.