-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
Search Terms
- suggest / suggestion / complete / completions
- TSServer
Background
Currently VS Code leaves it up to each extension/language to determine how completions work. Some languages implement completions so that selecting a completion replaces the current word:
c|onsole.log
// accept suggestion for `const` for cursor at pipe character
const.logWhile other languages instead opt to insert the selected completion at the current position without replacement:
c|onsole.log
// accept suggestion for `const` for cursor at pipe character
constonsole.logWith microsoft/vscode#10266, VS Code is considering adding a setting that lets users pick between using the replace vs insert behavior for suggestion
Proposal
To support this new setting, VS Code needs two ranges for each suggestion item:
- The range when in replacement mode
- The range when in insert mode
As we let the user dynamically select with type of insertion to use with a keybinding, both of these ranges need to be provided up front.
On the VS Code side, we can do a fairly reasonable job guessing at what the insert/replace range should be, but in order to be more reliable we'd need this information from the TS Server
Discussion
- Would this API proposal work for JS/TS?
- How does VS handle completions today (insert vs replace)? Is there any way to control this behavior?
- What are the cases where the insert/replace ranges would be different from what VS Code could compute itself? (bracket accessors or string literals for example) Maybe we only need to return additional range info in those cases?
/cc @minestarks @amcasey for VS
/cc @jrieken From VS Code