Skip to content

Commit 43f81e1

Browse files
committed
work with cmd+N but not clicking the "terminal" button
1 parent 5c3eba2 commit 43f81e1

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

frontend/app/store/keymodel.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getAllBlockComponentModels,
99
getApi,
1010
getBlockComponentModel,
11+
getSettingsKeyAtom,
1112
globalStore,
1213
refocusNode,
1314
WOS,
@@ -162,12 +163,23 @@ function globalRefocus() {
162163
}
163164

164165
async function handleCmdN() {
166+
const termAutoClose = globalStore.get(getSettingsKeyAtom("term:autoclose")) as boolean | undefined;
167+
const termAutoCloseOnError = globalStore.get(getSettingsKeyAtom("term:autocloseonerror")) as boolean | undefined;
168+
const termAutoCloseDelay = globalStore.get(getSettingsKeyAtom("term:autoclosedelay")) as number | undefined;
169+
165170
const termBlockDef: BlockDef = {
166171
meta: {
167172
view: "term",
168173
controller: "shell",
174+
"cmd:closeonexitforce": termAutoCloseOnError ?? false,
175+
"cmd:closeonexitdelay": termAutoCloseDelay ?? 2000,
169176
},
170177
};
178+
if (termAutoClose && !termAutoCloseOnError) {
179+
termBlockDef.meta["cmd:closeonexitforce"] = false;
180+
termBlockDef.meta["cmd:closeonexitdelay"] = termAutoCloseDelay ?? 2000;
181+
termBlockDef.meta["cmd:closeonexit"] = true;
182+
}
171183
const layoutModel = getLayoutModelForStaticTab();
172184
const focusedNode = globalStore.get(layoutModel.focusedNode);
173185
if (focusedNode != null) {

frontend/types/gotypes.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@ declare global {
601601
"term:copyonselect"?: boolean;
602602
"term:transparency"?: number;
603603
"term:allowbracketedpaste"?: boolean;
604+
"term:autoclose"?: boolean;
605+
"term:autocloseonerror"?: boolean;
606+
"term:autoclosedelay"?: number;
604607
"editor:minimapenabled"?: boolean;
605608
"editor:stickyscrollenabled"?: boolean;
606609
"editor:wordwrap"?: boolean;

pkg/wconfig/metaconsts.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const (
3535
ConfigKey_TermCopyOnSelect = "term:copyonselect"
3636
ConfigKey_TermTransparency = "term:transparency"
3737
ConfigKey_TermAllowBracketedPaste = "term:allowbracketedpaste"
38+
ConfigKey_TermAutoClose = "term:autoclose"
39+
ConfigKey_TermAutoCloseOnError = "term:autocloseonerror"
40+
ConfigKey_TermAutoCloseDelay = "term:autoclosedelay"
3841

3942
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
4043
ConfigKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"

pkg/wconfig/settingsconfig.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ type SettingsType struct {
6262
TermCopyOnSelect *bool `json:"term:copyonselect,omitempty"`
6363
TermTransparency *float64 `json:"term:transparency,omitempty"`
6464
TermAllowBracketedPaste *bool `json:"term:allowbracketedpaste,omitempty"`
65+
TermAutoClose *bool `json:"term:autoclose,omitempty"`
66+
TermAutoCloseOnError *bool `json:"term:autocloseonerror,omitempty"`
67+
TermAutoCloseDelay *float64 `json:"term:autoclosedelay,omitempty"`
6568

6669
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
6770
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`

0 commit comments

Comments
 (0)