Skip to content

Commit 91f7428

Browse files
authored
Merge branch 'Acode-Foundation:main' into lsp-codemirror
2 parents 9ef840b + 54b06e7 commit 91f7428

File tree

8 files changed

+84
-19
lines changed

8 files changed

+84
-19
lines changed

src/components/terminal/terminalDefaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const DEFAULT_TERMINAL_SETTINGS = {
1414
letterSpacing: 0,
1515
imageSupport: false,
1616
fontLigatures: false,
17+
confirmTabClose: true,
1718
// Touch selection settings
1819
touchSelectionTapHoldDuration: 600,
1920
touchSelectionMoveThreshold: 8,

src/components/terminal/terminalManager.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import EditorFile from "lib/editorFile";
77
import TerminalComponent from "./terminal";
88
import "@xterm/xterm/css/xterm.css";
99
import toast from "components/toast";
10+
import confirm from "dialogs/confirm";
11+
import appSettings from "lib/settings";
1012
import helpers from "utils/helpers";
1113

1214
const TERMINAL_SESSION_STORAGE_KEY = "acodeTerminalSessions";
@@ -413,6 +415,22 @@ class TerminalManager {
413415
this.closeTerminal(terminalId);
414416
};
415417

418+
terminalFile._skipTerminalCloseConfirm = false;
419+
const originalRemove = terminalFile.remove.bind(terminalFile);
420+
terminalFile.remove = async (force = false) => {
421+
if (
422+
!terminalFile._skipTerminalCloseConfirm &&
423+
this.shouldConfirmTerminalClose()
424+
) {
425+
const message = `${strings["close"]} ${strings["terminal"]}?`;
426+
const shouldClose = await confirm(strings["confirm"], message);
427+
if (!shouldClose) return;
428+
}
429+
430+
terminalFile._skipTerminalCloseConfirm = false;
431+
return originalRemove(force);
432+
};
433+
416434
// Enhanced resize handling with debouncing
417435
let resizeTimeout = null;
418436
const RESIZE_DEBOUNCE = 200;
@@ -519,6 +537,7 @@ class TerminalManager {
519537
}
520538

521539
this.closeTerminal(terminalId);
540+
terminalFile._skipTerminalCloseConfirm = true;
522541
terminalFile.remove(true);
523542
toast(message);
524543
};
@@ -731,6 +750,14 @@ class TerminalManager {
731750
}
732751
});
733752
}
753+
754+
shouldConfirmTerminalClose() {
755+
const settings = appSettings?.value?.terminalSettings;
756+
if (settings && settings.confirmTabClose === false) {
757+
return false;
758+
}
759+
return true;
760+
}
734761
}
735762

736763
// Create singleton instance

src/lang/hu-hu.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@
256256
"find file": "Fájl keresése",
257257
"system": "Rendszer",
258258
"please select a formatter": "Válasszon formátumkészítőt",
259-
"case sensitive": "Nagy-/kisbetű érzékeny",
260-
"regular expression": "Reguláris kifejezés",
261-
"whole word": "Egész szó",
259+
"case sensitive": "Kis- és nagybetűk megkülönböztetése",
260+
"regular expression": "Reguláris kifejezések",
261+
"whole word": "Illesztés csak teljes szóra",
262262
"edit with": "Szerkesztés ezzel",
263263
"open with": "Megnyitás ezzel",
264264
"no app found to handle this file": "Nem található alkalmazás a fájl kezelésére",

src/pages/fileBrowser/fileBrowser.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,14 +1333,16 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
13331333
* @param {String} url
13341334
*/
13351335
function pushToNavbar(name, url, action) {
1336+
if (!url) return;
1337+
const displayName = name || Url.basename(url) || url;
13361338
$navigation.append(
13371339
<span
13381340
id={getNavId(url)}
13391341
className="nav"
13401342
data-url={url}
1341-
data-name={name}
1343+
data-name={displayName}
13421344
attr-action="navigation"
1343-
attr-text={name}
1345+
attr-text={displayName}
13441346
tabIndex={-1}
13451347
></span>,
13461348
);
@@ -1359,14 +1361,20 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
13591361
* @param {Array<Location>} states
13601362
*/
13611363
function loadStates(states) {
1362-
if (!Array.isArray(states)) return;
1364+
if (!Array.isArray(states) || !states.length) return;
13631365

13641366
const backNavigation = [];
1365-
const { url, name } = states.pop();
1367+
const lastState = states.pop();
1368+
if (!lastState || !lastState.url) return;
1369+
const { url } = lastState;
1370+
const name = lastState.name || Url.basename(url) || url;
13661371
let { url: lastUrl, name: lastName } = currentDir;
13671372

13681373
while (states.length) {
13691374
const location = states.splice(0, 1)[0];
1375+
if (!location || !location.url) {
1376+
continue;
1377+
}
13701378
const { url, name } = location;
13711379
let action;
13721380

src/plugins/system/android/com/foxdebug/system/System.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,29 @@ private void hasPermission(String permission, CallbackContext callback) {
691691
}
692692

693693
public boolean fileExists(String path, String countSymlinks) {
694-
Path p = new File(path).toPath();
694+
boolean followSymlinks = !Boolean.parseBoolean(countSymlinks);
695+
File file = new File(path);
696+
697+
// Android < O does not implement File#toPath(), fall back to legacy checks
698+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
699+
if (!file.exists()) return false;
700+
if (followSymlinks) {
701+
try {
702+
// If canonical and absolute paths differ, it's a symlink
703+
return file.getCanonicalPath().equals(file.getAbsolutePath());
704+
} catch (IOException ignored) {
705+
return false;
706+
}
707+
}
708+
return true;
709+
}
710+
711+
Path p = file.toPath();
695712
try {
696-
if (Boolean.parseBoolean(countSymlinks)) {
697-
// This will return true even for broken symlinks
698-
return Files.exists(p, LinkOption.NOFOLLOW_LINKS);
699-
} else {
700-
// Check target file, not symlink itself
713+
if (followSymlinks) {
701714
return Files.exists(p) && !Files.isSymbolicLink(p);
715+
} else {
716+
return Files.exists(p, LinkOption.NOFOLLOW_LINKS);
702717
}
703718
} catch (Exception e) {
704719
return false;
@@ -1301,4 +1316,4 @@ private void setInputType(String type) {
13011316
}
13021317
webView.setInputType(mode);
13031318
}
1304-
}
1319+
}

src/plugins/websocket/www/websocket.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,21 @@ class WebSocketInstance extends EventTarget {
5858

5959
if (event.type === 'close') {
6060
this.readyState = WebSocketInstance.CLOSED;
61-
const closeEvent = new CloseEvent('close', { code: event.data?.code, reason: event.data?.reason });
61+
const closeData = event && event.data ? event.data : {};
62+
const closeEvent = new CloseEvent('close', {
63+
code: closeData.code,
64+
reason: closeData.reason,
65+
});
6266
if (this.onclose) this.onclose(closeEvent);
6367
this.dispatchEvent(closeEvent);
6468
}
6569

6670
if (event.type === 'error') {
67-
const errorEvent = new Event('error', { message: event?.data });
71+
const errorMessage = event && event.data ? event.data : undefined;
72+
const errorEvent = new Event('error');
73+
if (errorMessage !== undefined) {
74+
errorEvent.message = errorMessage;
75+
}
6876
if (this.onerror) this.onerror(errorEvent);
6977
this.dispatchEvent(errorEvent);
7078
}

src/settings/terminalSettings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ export default function terminalSettings() {
165165
checkbox: terminalValues.fontLigatures,
166166
info: "Whether font ligatures are enabled in the terminal.",
167167
},
168+
{
169+
key: "confirmTabClose",
170+
text: `${strings["confirm"]} ${strings["terminal"]} tab close`,
171+
checkbox: terminalValues.confirmTabClose !== false,
172+
info: "Ask for confirmation before closing terminal tabs.",
173+
},
168174
{
169175
key: "backup",
170176
text: strings.backup.capitalize(),

www/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
type,
4848
listener,
4949
useCapture,
50-
allowed,
50+
allowed
5151
) {
5252
if (typeof useCapture === "boolean") {
5353
allowed = useCapture;
@@ -76,7 +76,7 @@
7676
}
7777
this.eventListeners[type].push({
7878
listener: listener,
79-
useCapture: useCapture,
79+
useCapture: useCapture
8080
});
8181

8282
return;
@@ -159,4 +159,4 @@
159159
<wc-page id="root" class="primary"></wc-page>
160160
</body>
161161

162-
</html>
162+
</html>

0 commit comments

Comments
 (0)