Skip to content

Commit

Permalink
Use explicit text document for override completion path
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed Feb 25, 2024
1 parent d12c889 commit ee7a112
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
},
"defaults": {
"roslyn": "4.10.0-2.24123.4",
"roslyn": "4.10.0-2.24124.2",
"omniSharp": "1.39.11",
"razor": "7.0.0-preview.24115.3",
"razorOmnisharp": "7.0.0-preview.23363.1",
Expand Down
15 changes: 9 additions & 6 deletions src/lsptoolshost/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export function registerCommands(
context.subscriptions.push(
vscode.commands.registerCommand(
'roslyn.client.completionComplexEdit',
async (uriStr, textEdit, isSnippetString, newOffset) =>
completionComplexEdit(uriStr, textEdit, isSnippetString, newOffset, outputChannel)
async (textDocument, textEdit, isSnippetString, newOffset) =>
completionComplexEdit(textDocument, textEdit, isSnippetString, newOffset, outputChannel)
)
);
context.subscriptions.push(
Expand Down Expand Up @@ -97,7 +97,7 @@ async function restartServer(languageServer: RoslynLanguageServer): Promise<void
* @param newPosition The offset for new cursor position. -1 if the edit has not specified one.
*/
async function completionComplexEdit(
uriStr: string,
textDocument: languageClient.TextDocumentIdentifier,
textEdit: vscode.TextEdit,
isSnippetString: boolean,
newOffset: number,
Expand All @@ -106,18 +106,21 @@ async function completionComplexEdit(
const componentName = '[roslyn.client.completionComplexEdit]';

// Find TextDocument, opening if needed.
const uri = UriConverter.deserialize(uriStr);
const uri = UriConverter.deserialize(textDocument.uri);
const document = await vscode.workspace.openTextDocument(uri);
if (document === undefined) {
outputAndThrow(outputChannel, `${componentName} Can't open document with path: '${uriStr}'`);
outputAndThrow(outputChannel, `${componentName} Can't open document with path: '${textDocument.uri}'`);
}

// Use editor if we need to deal with selection or snippets.
let editor: vscode.TextEditor | undefined = undefined;
if (isSnippetString || newOffset >= 0) {
editor = await vscode.window.showTextDocument(document);
if (editor === undefined) {
outputAndThrow(outputChannel, `${componentName} Editor unavailable for document with path: '${uriStr}'`);
outputAndThrow(
outputChannel,
`${componentName} Editor unavailable for document with path: '${textDocument.uri}'`
);
}
}

Expand Down

0 comments on commit ee7a112

Please sign in to comment.