GithubHelp home page GithubHelp logo

Comments (4)

wellle avatar wellle commented on August 28, 2024

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.

orbisvicis avatar orbisvicis commented on August 28, 2024

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.

wellle avatar wellle commented on August 28, 2024

I see, I will consider handling quotes for argument text objects 👍

from targets.vim.

unphased avatar unphased commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.