@@ -32,7 +32,7 @@ export function registerCommands(
32
32
vscode . commands . registerCommand (
33
33
'roslyn.client.completionComplexEdit' ,
34
34
async ( uriStr , textEdit , isSnippetString , newOffset ) =>
35
- completionComplexEdit ( uriStr , textEdit , isSnippetString , newOffset )
35
+ completionComplexEdit ( uriStr , textEdit , isSnippetString , newOffset , outputChannel )
36
36
)
37
37
) ;
38
38
context . subscriptions . push (
@@ -100,22 +100,23 @@ async function completionComplexEdit(
100
100
uriStr : string ,
101
101
textEdit : vscode . TextEdit ,
102
102
isSnippetString : boolean ,
103
- newOffset : number
103
+ newOffset : number ,
104
+ outputChannel : vscode . OutputChannel
104
105
) : Promise < void > {
105
106
const componentName = '[roslyn.client.completionComplexEdit]' ;
106
107
107
108
// Find TextDocument, opening if needed.
108
109
const document = await vscode . workspace . openTextDocument ( uriStr ) ;
109
110
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 } '` ) ;
111
112
}
112
113
113
114
// Use editor if we need to deal with selection or snippets.
114
115
let editor : vscode . TextEditor | undefined = undefined ;
115
116
if ( isSnippetString || newOffset >= 0 ) {
116
117
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 } '` ) ;
119
120
}
120
121
}
121
122
@@ -155,12 +156,19 @@ async function completionComplexEdit(
155
156
}
156
157
157
158
if ( ! success ) {
158
- throw new Error (
159
+ outputAndThrow (
160
+ outputChannel ,
159
161
`${ componentName } ${ isSnippetString ? 'TextEditor.insertSnippet' : 'workspace.applyEdit' } failed.`
160
162
) ;
161
163
}
162
164
}
163
165
166
+ function outputAndThrow ( outputChannel : vscode . OutputChannel , message : string ) : void {
167
+ outputChannel . show ( ) ;
168
+ outputChannel . appendLine ( message ) ;
169
+ throw new Error ( message ) ;
170
+ }
171
+
164
172
async function openSolution ( languageServer : RoslynLanguageServer ) : Promise < vscode . Uri | undefined > {
165
173
if ( ! vscode . workspace . workspaceFolders ) {
166
174
return undefined ;
0 commit comments