microsoft / microsoft/language-server-protocol

Smart identation for `TextEdit`

Open
#1,703 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

image
image

I want to insert a extra line in textDocument/completion requests by additionalTextEdits.
However since I don't know the identation in this requests, I cannot choose the correct identation in TextEdit.
I know I can analyze context to guess the identation, but I hope this can be done by the client because the client knows the most correct indentation.

Currenty, if I set InsertTextFormat to Snippet, the \t in insertText can be smartly replaced to correct indentation.
So I hope TextEdit can support similar feature, for example:

interface TextEdit {
	/**
	 * The range of the text document to be manipulated. To insert
	 * text into a document create a range where start === end.
	 */
	range: Range;

	/**
	 * The string to be inserted. For delete operations use an
	 * empty string.
	 */
	newText: string;

	/**
	 * + 1: as is
	 * + 2: replace `\t` with correct indentation
	 */
	textFormat?: 1 | 2;
}

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

Start with the TextEdit and InsertTextFormat definitions in the LSP specification and compare them with the textDocument/completion request behavior described here. Determine whether client-side indentation for additionalTextEdits can be specified without ambiguity, and document the accepted protocol design and its completion semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.