File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
apps/vscode/src/providers/editor Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -164,16 +164,22 @@ export class VisualEditorProvider implements CustomTextEditorProvider {
164164 this . editorPendingSwitchToVisual . delete ( uri . toString ( ) ) ;
165165 }
166166
167+ // The `tab` we get from the change event is not precisely the same
168+ // as the tab in `window.tabGroups`, so if we try and close `tab` we
169+ // get a "tab not found" error. The one we care about does exist, but we have
170+ // manually find it via URI, which is a stable field to match on.
167171 if ( editorMode && editorMode != viewType && ! isSwitch ) {
168172 const allTabs = window . tabGroups . all . flatMap ( group => group . tabs ) ;
169173
170174 // find tab to close if swapping editor type
171- const tabsToClose = allTabs . filter ( tab =>
175+ const tabToClose = allTabs . find ( tab =>
172176 ( ( tab . input instanceof TabInputText ) || ( tab . input instanceof TabInputCustom ) ) &&
173177 ( tab . input ?. uri ?. toString ( ) === uri ?. toString ( ) )
174178 ) ;
175-
176- await window . tabGroups . close ( tabsToClose , true ) ;
179+ if ( ! tabToClose ) {
180+ return ;
181+ }
182+ await window . tabGroups . close ( tabToClose , true ) ;
177183 await commands . executeCommand ( "vscode.openWith" , uri , editorMode ) ;
178184 return ;
179185 }
You can’t perform that action at this time.
0 commit comments