Skip to content

Commit 324b354

Browse files
committed
Revert "CR feedback"
This reverts commit 29bb640.
1 parent 29bb640 commit 324b354

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/lsptoolshost/commands.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function registerCommands(
3232
vscode.commands.registerCommand(
3333
'roslyn.client.completionComplexEdit',
3434
async (uriStr, textEdit, isSnippetString, newOffset) =>
35-
completionComplexEdit(uriStr, textEdit, isSnippetString, newOffset)
35+
completionComplexEdit(uriStr, textEdit, isSnippetString, newOffset, outputChannel)
3636
)
3737
);
3838
context.subscriptions.push(
@@ -100,22 +100,23 @@ async function completionComplexEdit(
100100
uriStr: string,
101101
textEdit: vscode.TextEdit,
102102
isSnippetString: boolean,
103-
newOffset: number
103+
newOffset: number,
104+
outputChannel: vscode.OutputChannel
104105
): Promise<void> {
105106
const componentName = '[roslyn.client.completionComplexEdit]';
106107

107108
// Find TextDocument, opening if needed.
108109
const document = await vscode.workspace.openTextDocument(uriStr);
109110
if (document === undefined) {
110-
throw new Error(`${componentName} Can't open document with path: '${uriStr}'`);
111+
outputAndThrow(outputChannel, `${componentName} Can't open document with path: '${uriStr}'`);
111112
}
112113

113114
// Use editor if we need to deal with selection or snippets.
114115
let editor: vscode.TextEditor | undefined = undefined;
115116
if (isSnippetString || newOffset >= 0) {
116117
editor = await vscode.window.showTextDocument(document);
117-
if (editor === undefined) {
118-
throw new Error(`${componentName} Editor unavailable for document with path: '${uriStr}'`);
118+
if (editor == undefined) {
119+
outputAndThrow(outputChannel, `${componentName} Editor unavailable for document with path: '${uriStr}'`);
119120
}
120121
}
121122

@@ -155,12 +156,19 @@ async function completionComplexEdit(
155156
}
156157

157158
if (!success) {
158-
throw new Error(
159+
outputAndThrow(
160+
outputChannel,
159161
`${componentName} ${isSnippetString ? 'TextEditor.insertSnippet' : 'workspace.applyEdit'} failed.`
160162
);
161163
}
162164
}
163165

166+
function outputAndThrow(outputChannel: vscode.OutputChannel, message: string): void {
167+
outputChannel.show();
168+
outputChannel.appendLine(message);
169+
throw new Error(message);
170+
}
171+
164172
async function openSolution(languageServer: RoslynLanguageServer): Promise<vscode.Uri | undefined> {
165173
if (!vscode.workspace.workspaceFolders) {
166174
return undefined;

0 commit comments

Comments
 (0)