Skip to content

Commit 19967db

Browse files
akhera99dibarbet
andauthored
Fix Auto Insert XML Comment Issue (#6130)
* fixes * Update src/lsptoolshost/roslynLanguageServer.ts Co-authored-by: David Barbet <[email protected]> --------- Co-authored-by: David Barbet <[email protected]>
1 parent 6322c77 commit 19967db

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)