Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Auto Insert XML Comment Issue #6130

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,12 @@ async function applyAutoInsertEdit(
token: vscode.CancellationToken
) {
const change = e.contentChanges[0];

// Need to add 1 since the server expects the position to be where the caret is after the last token has been inserted.
const position = new vscode.Position(change.range.start.line, change.range.start.character + 1);
// The server expects the request position to represent the caret position in the text after the change has already been applied.
// We need to calculate what that position would be after the change is applied and send that to the server.
Comment on lines +864 to +865
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ Can you point me to the public LSP specification documentation for this behavior?

const position = new vscode.Position(
change.range.start.line,
change.range.start.character + (change.text.length - change.rangeLength)
);
const uri = UriConverter.serialize(e.document.uri);
const textDocument = TextDocumentIdentifier.create(uri);
const formattingOptions = getFormattingOptions();
Expand Down