Git Product home page Git Product logo

Comments (7)

dbaeumer avatar dbaeumer commented on May 23, 2024

Can you please explain in more detail why this is currently ambiguous.

from language-server-protocol.

spotandjake avatar spotandjake commented on May 23, 2024

an example in vscode is when you are selecting a variable somewhere take value if you select from left to right you will get the cursor positon after the e and if you select right to left, you get the position before the v. it would be more imformative if the selection range was provided as well. that way the selected value could be provided rather than the cursor position. if you are selection a range and clicking go to definition it would be the most helpful and most reasonable to get the info about the selected range rather then where the cursor ends on your selection.

I hope that makes sense.

from language-server-protocol.

dbaeumer avatar dbaeumer commented on May 23, 2024

I see that point but I don't understand in which cases this would lead to a different result of the request. Changing this is a breaking change unless we provide both infos and I would like to understand when this is useful in case of computing a more precise result.

from language-server-protocol.

spotandjake avatar spotandjake commented on May 23, 2024

I am proposing providing both as I think both could be useful. When you are looking up the identifier requested if the symbol is the symbol after what is selected how is an lsp to know that you wanted the specified identifier and not whatever symbol comes next. When working on an lsp I was having an issue that it wasn't clear that the user was selecting var1 in the statement var1+var2 because when they selected from left to right their cursor position was at the +

An alternative though breaking change would also be to enforce that the position is either the cursor position or the starting position of the selection range.

from language-server-protocol.

dbaeumer avatar dbaeumer commented on May 23, 2024

I see that case but I am not sure it is worth the swirl that such a change will cause.

from language-server-protocol.

davidhalter avatar davidhalter commented on May 23, 2024

An alternative though breaking change would also be to enforce that the position is either the cursor position or the starting position of the selection range.

This is not something that the protocol should enforce IMO. This is something that editors can handle in arbitrary ways.


I feel like the additional information might be slightly useful, but it's definitely not worth the hassle here. The additional information would probably just help to avoid sending information to the user that he does not wants. For example:

If you select var1+var2, a DefintionRequest is ambiguous, because it's unclear if the definition of var1 or var2 is requested and the server should probably return an error. However these are probably rare cases even for users and even if the server returns the definition of var1 or var2, that's probably still fine as a user.

Note however that in the original example @spotandjake mentions that

user was selecting var1 in the statement var1+var2 because when they selected from left to right their cursor position was at the +

IMO this is an error of the language server. If var1 is selected, the cursor is between 1 and +, which means the server has all the information it needs to know that the definition of var1 is requested.

from language-server-protocol.

spotandjake avatar spotandjake commented on May 23, 2024

An alternative though breaking change would also be to enforce that the position is either the cursor position or the starting position of the selection range.

This is not something that the protocol should enforce IMO. This is something that editors can handle in arbitrary ways.

I feel like the additional information might be slightly useful, but it's definitely not worth the hassle here. The additional information would probably just help to avoid sending information to the user that he does not wants. For example:

If you select var1+var2, a DefintionRequest is ambiguous, because it's unclear if the definition of var1 or var2 is requested and the server should probably return an error. However these are probably rare cases even for users and even if the server returns the definition of var1 or var2, that's probably still fine as a user.

Note however that in the original example @spotandjake mentions that

user was selecting var1 in the statement var1+var2 because when they selected from left to right their cursor position was at the +

IMO this is an error of the language server. If var1 is selected, the cursor is between 1 and +, which means the server has all the information it needs to know that the definition of var1 is requested.

A better example of the problem i am getting at is, in a language with custom operators given the example of foo1|+foo2 where | represents the cursor location. Its ambigous to the lsp as to weather the user is selecting left to right over foo1 and wants the definition of foo1, or if the user is selecting right to left on + and actually wants the definition of +.

I dont think my early examples were specific enough sorry.

from language-server-protocol.

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.