Comments (7)
Can you please explain in more detail why this is currently ambiguous.
from language-server-protocol.
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.
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.
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.
I see that case but I am not sure it is worth the swirl that such a change will cause.
from language-server-protocol.
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.
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 ofvar1
orvar2
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 between1
and+
, which means the server has all the information it needs to know that the definition ofvar1
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)
- MetaModel.json use during LSP implementation HOT 12
- Specify exactly what "the client will normalize line ending characters" means HOT 2
- Clarify docs: deltaLine and deltaStart fields of semantic tokens relate to the _start_ of the previous token HOT 2
- MetaModel: Missing Types and `TraceValue` vs `TraceValues` HOT 2
- What's the difference about deprecated in Diagnostic and Semantic Token? HOT 2
- Range property in TextDocumentContentChangeEvent inconsistent with comment HOT 1
- Can a client use `window/workDoneProgress/cancel` to cancel a progress token provided by the client? HOT 8
- Add 'linewidth' parameter to 'formatting_options' HOT 1
- Define/document the ways in which clients may/may not change custom-scheme URIs provided by the server
- Unclear handling of nil diagnostic responses
- When are params and error data optional?
- Command line utility for lsp client HOT 1
- Support multiple output channels for log message notifications
- Better document HOT 4
- Server capability for configuration change notifications? HOT 12
- Detailed explain on semantic token types?
- Recommend relationship between error ranges and selections for quickfixes HOT 1
- Clarification on integers and enums HOT 1
- Add "generated" to `SymbolTag`
- Define POSIX (POSIX.1-2017) as a standard regular expression variant HOT 3
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 language-server-protocol.