-
Notifications
You must be signed in to change notification settings - Fork 13.3k
TS Server API proposal: Commit Characters #27623
Copy link
Copy link
Closed
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueDomain: LS: TSServerIssues related to the TSServerIssues related to the TSServerFix AvailableA PR has been opened for this issueA PR has been opened for this issueIn DiscussionNot yet reached consensusNot yet reached consensusRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestoneSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Metadata
Metadata
Assignees
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueDomain: LS: TSServerIssues related to the TSServerIssues related to the TSServerFix AvailableA PR has been opened for this issueA PR has been opened for this issueIn DiscussionNot yet reached consensusNot yet reached consensusRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestoneSuggestionAn idea for TypeScriptAn idea for TypeScript
Problem
VS Code (and Visual Studio) have the concept of commit characters for suggestions. This is a set of characters that, when typed, accept the current suggestion. For example, a suggestion for a function may treat
(as a commit character.VS Code currently computes these commit characters itself using the metadata that typescript returns for each completion entry. This has two problems:
This logic is VS Code specific and may be out of sync with how VS and other editors handle commit characters.
There are some cases where it is difficult to determine what the commit characters should be. A classic example is:
Where the user has just typed
.. Currently we show a suggestion forbwhen the user types the.. If the user then types another.as part of a spread, we incorrectly end up accepting that completion, which leaves the code as:TypeScript, with its access to the ast, should be able to determine that
.should not be a commit character in this caseProposal
Introduce the concept of a commit characters to the TypeScript server aAPI. This would be an optional set of characters returned on each
CompletionEntry:Return these commit characters on completions. Here's an approximation of how VS Code computes commit characters:
.and;are commit characters for most completion types except for keywords and a few others.(and,are commit characters for variables.isNewIdentifierLocationis set.