@@ -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,6 +149,27 @@ async function completionComplexEdit(
142
149
}
143
150
144
151
if ( ! success ) {
152
+ const componentName = '[roslyn.client.completionComplexEdit]' ;
153
+
154
+ if ( editor === undefined ) {
155
+ outputChannel . show ( ) ;
156
+ outputChannel . appendLine ( `${ componentName } Failed to make a complex text edit for completion.` ) ;
157
+ outputChannel . appendLine (
158
+ `${ componentName } Can't find visible document with uri.fsPath: '${ uri . fsPath } ' and uri.path: '${ uri . path } '`
159
+ ) ;
160
+
161
+ outputChannel . appendLine ( `${ componentName } URIs of all visible documents:` ) ;
162
+ for ( const visibleEditor of vscode . window . visibleTextEditors ) {
163
+ outputChannel . appendLine (
164
+ `${ componentName } - uri.fsPath: '${ visibleEditor . document . uri . fsPath } ' and uri.path: '${ visibleEditor . document . uri . path } '`
165
+ ) ;
166
+ }
167
+ } else {
168
+ outputChannel . appendLine (
169
+ `${ componentName } ${ isSnippetString ? 'TextEditor.insertSnippet' : 'workspace.applyEdit' } failed.`
170
+ ) ;
171
+ }
172
+
145
173
throw new Error ( 'Failed to make a complex text edit for completion.' ) ;
146
174
}
147
175
}
0 commit comments