@@ -31,7 +31,11 @@ export function registerCommands(
31
31
// so we don't accidentally pass them directly into vscode APIs.
32
32
context . subscriptions . push ( vscode . commands . registerCommand ( 'roslyn.client.peekReferences' , peekReferencesCallback ) ) ;
33
33
context . subscriptions . push (
34
- vscode . commands . registerCommand ( 'roslyn.client.completionComplexEdit' , completionComplexEdit )
34
+ vscode . commands . registerCommand (
35
+ 'roslyn.client.completionComplexEdit' ,
36
+ async ( uriStr , textEdit , isSnippetString , newOffset ) =>
37
+ completionComplexEdit ( uriStr , textEdit , isSnippetString , newOffset , outputChannel )
38
+ )
35
39
) ;
36
40
context . subscriptions . push (
37
41
vscode . commands . registerCommand ( 'dotnet.restartServer' , async ( ) => restartServer ( languageServer ) )
@@ -99,11 +103,14 @@ async function completionComplexEdit(
99
103
uriStr : string ,
100
104
textEdit : vscode . TextEdit ,
101
105
isSnippetString : boolean ,
102
- newOffset : number
106
+ newOffset : number ,
107
+ outputChannel : vscode . OutputChannel
103
108
) : Promise < void > {
104
109
let success = false ;
105
110
const uri = UriConverter . deserialize ( uriStr ) ;
106
- const editor = vscode . window . visibleTextEditors . find ( ( editor ) => editor . document . uri . fsPath === uri . fsPath ) ;
111
+ const editor = vscode . window . visibleTextEditors . find (
112
+ ( editor ) => editor . document . uri . path === uri . path || editor . document . uri . fsPath === uri . fsPath
113
+ ) ;
107
114
108
115
if ( editor !== undefined ) {
109
116
const newRange = editor . document . validateRange (
@@ -142,7 +149,29 @@ async function completionComplexEdit(
142
149
}
143
150
144
151
if ( ! success ) {
145
- throw new Error ( 'Failed to make a complex text edit for completion.' ) ;
152
+ const componentName = '[roslyn.client.completionComplexEdit]' ;
153
+ const errorMessage = 'Failed to make a complex text edit for completion.' ;
154
+ outputChannel . show ( ) ;
155
+ outputChannel . appendLine ( `${ componentName } ${ errorMessage } ` ) ;
156
+
157
+ if ( editor === undefined ) {
158
+ outputChannel . appendLine (
159
+ `${ componentName } Can't find visible document with uri.fsPath: '${ uri . fsPath } ' and uri.path: '${ uri . path } '`
160
+ ) ;
161
+
162
+ outputChannel . appendLine ( `${ componentName } URIs of all visible documents:` ) ;
163
+ for ( const visibleEditor of vscode . window . visibleTextEditors ) {
164
+ outputChannel . appendLine (
165
+ `${ componentName } - uri.fsPath: '${ visibleEditor . document . uri . fsPath } ' and uri.path: '${ visibleEditor . document . uri . path } '`
166
+ ) ;
167
+ }
168
+ } else {
169
+ outputChannel . appendLine (
170
+ `${ componentName } ${ isSnippetString ? 'TextEditor.insertSnippet' : 'workspace.applyEdit' } failed.`
171
+ ) ;
172
+ }
173
+
174
+ throw new Error ( `${ componentName } ${ errorMessage } ` ) ;
146
175
}
147
176
}
148
177
0 commit comments