File tree 2 files changed +16
-2
lines changed 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -97,10 +97,14 @@ const KEYMAP = [
97
97
} ,
98
98
{
99
99
keys : [ "ctrl+w" , "command+w" ] ,
100
- description : "Close active tab" ,
100
+ description :
101
+ "Close active tab or focus previously activated tab if active tab pinned" ,
101
102
action : ( ) => {
102
103
const activeTab = useEditorStore . getState ( ) . getActiveTab ( ) ;
103
- if ( activeTab ?. pinned ) return ;
104
+ if ( activeTab ?. pinned ) {
105
+ useEditorStore . getState ( ) . focusPreviouslyActivatedTab ( ) ;
106
+ return ;
107
+ }
104
108
useEditorStore . getState ( ) . closeActiveTab ( ) ;
105
109
}
106
110
} ,
Original file line number Diff line number Diff line change @@ -850,6 +850,16 @@ class EditorStore extends BaseStore<EditorStore> {
850
850
return this . focusTab ( tabs [ index === 0 ? tabs . length - 1 : index - 1 ] . id ) ;
851
851
} ;
852
852
853
+ focusPreviouslyActivatedTab = ( ) => {
854
+ const history = useEditorStore . getState ( ) . history ;
855
+ if ( history . length < 2 ) return ;
856
+
857
+ const previousTab = history . at ( - 2 ) ;
858
+ if ( ! previousTab ) return ;
859
+
860
+ useEditorStore . getState ( ) . focusTab ( previousTab ) ;
861
+ } ;
862
+
853
863
goBack = async ( ) => {
854
864
const activeTabId = this . get ( ) . activeTabId ;
855
865
if ( ! activeTabId || ! tabSessionHistory . canGoBack ( activeTabId ) ) return ;
You can’t perform that action at this time.
0 commit comments