microsoft / microsoft/language-server-protocol

Provide range or bias direction for go-to-definition etc

Open
#1,029 22 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request goto
Dominant language
TypeScript
Stars
13k
Forks
1k
Avg merge
6d 1h
Merged PRs (30d)
10

Description

Go-to-definition (and others) is triggered on a cursor position. In VSCode, the cursor lies between characters, so ambiguity: the thing on the left or the thing on the right?

A couple of factors make this worse:

  • having a selection resolves the ambiguity, but the language server doesn't get to see it. In VSCode a selection usually requires biasing left.
  • other editors place the cursor on characters and so have no ambiguity. They always need the language server to bias right.

To illustrate, these screenshots produce the same textDocument/definition request, but want different results.

In vim. This should go to Foo::operator->.
image

In VSCode. This should go to object.
image

It'd be nice to have some more information so language servers can make better decisions. Some ideas:

  • requests provide optional selection range in addition to cursor position. (block-cursor editors might always provide at least a 1-char range)
  • a client capability describing the cursor type. (Language servers could implement heuristics like bias-towards-identifier for cursor-between-char editors, and have the correct behavior for block-cursor editors)

I guess this is mostly an issue with languages that have overloaded operators. constructor and functor calls are common examples in C++.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no file or test. Begin by reviewing the protocol's position-related request definitions and the proposed selection-range or cursor-capability approaches; done would be an agreed protocol design and corresponding specification change.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vim, vscode
Domain
api, developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.