File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -972,9 +972,12 @@ async function applyAutoInsertEdit(
972972 token : vscode . CancellationToken
973973) {
974974 const change = e . contentChanges [ 0 ] ;
975-
976- // Need to add 1 since the server expects the position to be where the caret is after the last token has been inserted.
977- const position = new vscode . Position ( change . range . start . line , change . range . start . character + 1 ) ;
975+ // The server expects the request position to represent the caret position in the text after the change has already been applied.
976+ // We need to calculate what that position would be after the change is applied and send that to the server.
977+ const position = new vscode . Position (
978+ change . range . start . line ,
979+ change . range . start . character + ( change . text . length - change . rangeLength )
980+ ) ;
978981 const uri = UriConverter . serialize ( e . document . uri ) ;
979982 const textDocument = TextDocumentIdentifier . create ( uri ) ;
980983 const formattingOptions = getFormattingOptions ( ) ;
You can’t perform that action at this time.
0 commit comments