Skip to content

Commit 16053f9

Browse files
committed
feat(terminal): improve close confirmation dialogs with context-specific messages
Use distinct dialog titles, messages, and button labels for three scenarios: single terminal with active process, multiple idle terminals, and multiple terminals with active processes. Singular/plural forms use separate i18n keys for proper translation support.
1 parent 810d7cb commit 16053f9

2 files changed

Lines changed: 50 additions & 18 deletions

File tree

src/extensionsIntegrated/Terminal/main.js

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ define(function (require, exports, module) {
3636
const NodeConnector = require("NodeConnector");
3737
const Mustache = require("thirdparty/mustache/mustache");
3838
const Dialogs = require("widgets/Dialogs");
39+
const DefaultDialogs = require("widgets/DefaultDialogs");
3940
const Strings = require("strings");
4041
const StringUtils = require("utils/StringUtils");
4142

@@ -605,23 +606,48 @@ define(function (require, exports, module) {
605606
}
606607
}
607608

608-
if (terminalInstances.length > 1 || activeProcesses.length > 0) {
609-
const msgKey = activeProcesses.length > 0
610-
? Strings.TERMINAL_CLOSE_ALL_MSG_PROCESS
611-
: Strings.TERMINAL_CLOSE_ALL_MSG;
612-
const message = StringUtils.format(
613-
msgKey, terminalInstances.length, activeProcesses.length
614-
);
615-
const dialog = Dialogs.showConfirmDialog(
616-
Strings.TERMINAL_CLOSE_ALL_TITLE, message
617-
);
618-
const buttonId = await dialog.getPromise();
619-
if (buttonId !== Dialogs.DIALOG_BTN_OK) {
620-
return false;
621-
}
609+
let title, message, confirmText;
610+
const count = terminalInstances.length;
611+
const procCount = activeProcesses.length;
612+
613+
if (count === 1 && procCount > 0) {
614+
// Single terminal with an active process
615+
title = Strings.TERMINAL_CLOSE_SINGLE_TITLE;
616+
message = Strings.TERMINAL_CLOSE_SINGLE_MSG;
617+
confirmText = Strings.TERMINAL_CLOSE_SINGLE_BTN;
618+
} else if (count > 1 && procCount === 0) {
619+
// Multiple terminals, no active processes
620+
title = Strings.TERMINAL_CLOSE_ALL_TITLE;
621+
message = Strings.TERMINAL_CLOSE_ALL_MSG;
622+
confirmText = Strings.TERMINAL_CLOSE_ALL_BTN;
623+
} else if (count > 1 && procCount > 0) {
624+
// Multiple terminals, some with active processes
625+
title = Strings.TERMINAL_CLOSE_ALL_TITLE;
626+
message = procCount === 1
627+
? Strings.TERMINAL_CLOSE_ALL_MSG_PROCESS_ONE
628+
: StringUtils.format(Strings.TERMINAL_CLOSE_ALL_MSG_PROCESS_MANY, procCount);
629+
confirmText = Strings.TERMINAL_CLOSE_ALL_STOP_BTN;
630+
} else {
631+
// Single idle terminal — no confirmation needed
632+
_disposeAll();
633+
activeTerminalId = null;
634+
_updateFlyout();
635+
return true;
636+
}
637+
638+
const buttons = [
639+
{className: Dialogs.DIALOG_BTN_CLASS_NORMAL, id: Dialogs.DIALOG_BTN_CANCEL, text: Strings.CANCEL},
640+
{className: Dialogs.DIALOG_BTN_CLASS_PRIMARY, id: Dialogs.DIALOG_BTN_OK, text: confirmText}
641+
];
642+
const dialog = Dialogs.showModalDialog(
643+
DefaultDialogs.DIALOG_ID_INFO, title, message, buttons
644+
);
645+
const buttonId = await dialog.getPromise();
646+
if (buttonId !== Dialogs.DIALOG_BTN_OK) {
647+
return false;
622648
}
623649

624-
// User confirmed (or single idle terminal) — dispose everything
650+
// User confirmed — dispose everything
625651
_disposeAll();
626652
activeTerminalId = null;
627653
_updateFlyout();

src/nls/root/strings.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,9 +1488,15 @@ define({
14881488
"ERROR_TERMINAL_NOT_FOUND": "Terminal was not found for your OS, you can define a custom Terminal command in the settings",
14891489
"TERMINAL_CLOSE_CONFIRM_TITLE": "Active Process Running",
14901490
"TERMINAL_CLOSE_CONFIRM_MSG": "Terminal has an active process running: <b>{0}</b>.<br>Are you sure you want to close it?",
1491-
"TERMINAL_CLOSE_ALL_TITLE": "Close All Terminals",
1492-
"TERMINAL_CLOSE_ALL_MSG": "This will close {0} terminal(s).<br>Continue?",
1493-
"TERMINAL_CLOSE_ALL_MSG_PROCESS": "This will close {0} terminal(s). {1} have active processes that will be terminated.<br>Continue?",
1491+
"TERMINAL_CLOSE_SINGLE_TITLE": "Close Terminal?",
1492+
"TERMINAL_CLOSE_SINGLE_MSG": "This terminal has an active process. Closing it will stop the process.<br>Do you want to continue?",
1493+
"TERMINAL_CLOSE_SINGLE_BTN": "Close Terminal",
1494+
"TERMINAL_CLOSE_ALL_TITLE": "Close All Terminals?",
1495+
"TERMINAL_CLOSE_ALL_MSG": "All terminals will be closed.<br>No active processes are running.<br><br>Continue?",
1496+
"TERMINAL_CLOSE_ALL_BTN": "Close All",
1497+
"TERMINAL_CLOSE_ALL_MSG_PROCESS_ONE": "All terminals will be closed.<br>1 active process will be stopped.<br><br>Continue?",
1498+
"TERMINAL_CLOSE_ALL_MSG_PROCESS_MANY": "All terminals will be closed.<br>{0} active processes will be stopped.<br><br>Continue?",
1499+
"TERMINAL_CLOSE_ALL_STOP_BTN": "Close All & Stop Processes",
14941500
"TERMINAL_FOCUS_HINT": "Press {0} to switch between editor and terminal",
14951501
"EXTENDED_COMMIT_MESSAGE": "EXTENDED",
14961502
"GETTING_STAGED_DIFF_PROGRESS": "Getting diff of staged files\u2026",

0 commit comments

Comments
 (0)