Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.6/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.11/schema.json",
"formatter": {
"enabled": true,
"indentStyle": "tab"
Expand Down
72 changes: 36 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@babel/preset-typescript": "^7.28.5",
"@babel/runtime": "^7.28.4",
"@babel/runtime-corejs3": "^7.28.4",
"@biomejs/biome": "2.4.6",
"@biomejs/biome": "2.4.11",
"@rspack/cli": "^1.7.0",
"@rspack/core": "^1.7.0",
"@types/ace": "^0.0.52",
Expand Down
2 changes: 1 addition & 1 deletion src/cm/lsp/codeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,4 +415,4 @@ export async function performQuickFix(view: EditorView): Promise<boolean> {
return showCodeActionsMenu(view);
}

export { CODE_ACTION_KINDS, getCodeActionIcon, formatCodeActionKind };
export { CODE_ACTION_KINDS, formatCodeActionKind, getCodeActionIcon };
10 changes: 5 additions & 5 deletions src/cm/lsp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export type {
LSPClient,
LSPClientConfig,
LSPClientExtension,
LSPDiagnostic,
LSPFormattingOptions,
Position,
Range,
TextEdit,
Transport,
Workspace,
WorkspaceFile,
TextEdit,
LSPFormattingOptions,
LSPDiagnostic,
Range,
Position,
};

export interface WorkspaceFileUpdate {
Expand Down
2 changes: 1 addition & 1 deletion src/components/lspInfoDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,5 +704,5 @@ function hasConnectedServers() {
return relevantServers.length > 0;
}

export { showLspInfoDialog, hasConnectedServers, addLspLog, getLspLogs };
export { addLspLog, getLspLogs, hasConnectedServers, showLspInfoDialog };
export default showLspInfoDialog;
2 changes: 1 addition & 1 deletion src/components/terminal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import TerminalManager from "./terminalManager";
import TerminalThemeManager from "./terminalThemeManager";

export {
DEFAULT_TERMINAL_SETTINGS,
TerminalComponent,
TerminalManager,
TerminalThemeManager,
DEFAULT_TERMINAL_SETTINGS,
};

export default {
Expand Down
2 changes: 2 additions & 0 deletions src/test/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { runAceCompatibilityTests } from "./ace.test";
import { runCodeMirrorTests } from "./editor.tests";
import { runExecutorTests } from "./exec.tests";
import { runSanityTests } from "./sanity.tests";
import { runUrlTests } from "./url.tests";

export async function runAllTests() {
const terminal = acode.require("terminal");
Expand All @@ -20,6 +21,7 @@ export async function runAllTests() {
await runCodeMirrorTests(write);
await runAceCompatibilityTests(write);
await runExecutorTests(write);
await runUrlTests(write);

write("\x1b[36m\x1b[1mTests completed!\x1b[0m\n");
} catch (error) {
Expand Down
96 changes: 96 additions & 0 deletions src/test/url.tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import Url from "../utils/Url";
import { TestRunner } from "./tester";

const JOIN_CASES = [
{
name: "Android SAF join",
folderUrl:
"content://com.android.externalstorage.documents/tree/primary%3ATesthtml",
activeLocation:
"content://com.android.externalstorage.documents/tree/primary%3ATesthtml::primary:Testhtml/Styles/",
expectedJoined:
"content://com.android.externalstorage.documents/tree/primary%3ATesthtml::primary:Testhtml/Styles/index.html",
},
{
name: "Termux SAF join",
folderUrl:
"content://com.termux.documents/tree/%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fhome%2Facode-site-ui",
activeLocation:
"content://com.termux.documents/tree/%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fhome%2Facode-site-ui::/data/data/com.termux/files/home/acode-site-ui/",
expectedJoined:
"content://com.termux.documents/tree/%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fhome%2Facode-site-ui::/data/data/com.termux/files/home/acode-site-ui/index.html",
},
{
name: "Acode SAF join",
folderUrl:
"content://com.foxdebug.acode.documents/tree/%2Fdata%2Fuser%2F0%2Fcom.foxdebug.acode%2Ffiles%2Fpublic",
activeLocation:
"content://com.foxdebug.acode.documents/tree/%2Fdata%2Fuser%2F0%2Fcom.foxdebug.acode%2Ffiles%2Fpublic::/data/user/0/com.foxdebug.acode/files/public/",
expectedJoined:
"content://com.foxdebug.acode.documents/tree/%2Fdata%2Fuser%2F0%2Fcom.foxdebug.acode%2Ffiles%2Fpublic::/data/user/0/com.foxdebug.acode/files/public/index.html",
},
];

const TRAILING_SLASH_CASES = [
{
name: "Android SAF trailing slash",
a: "content://com.android.externalstorage.documents/tree/primary%3ATesthtml/",
b: "content://com.android.externalstorage.documents/tree/primary%3ATesthtml",
},
{
name: "Termux SAF trailing slash",
a: "content://com.termux.documents/tree/%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fhome%2Facode-site-ui/",
b: "content://com.termux.documents/tree/%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fhome%2Facode-site-ui",
},
{
name: "Acode SAF trailing slash",
a: "content://com.foxdebug.acode.documents/tree/%2Fdata%2Fuser%2F0%2Fcom.foxdebug.acode%2Ffiles%2Fpublic/",
b: "content://com.foxdebug.acode.documents/tree/%2Fdata%2Fuser%2F0%2Fcom.foxdebug.acode%2Ffiles%2Fpublic",
},
];

function assertJoinCase(
test,
{ folderUrl, activeLocation, expectedJoined, segment },
) {
const joined = Url.join(activeLocation, segment || "index.html");

test.assert(joined !== null, "Joining the SAF URL should return a value");
test.assertEqual(
joined,
expectedJoined,
"Joined URL should match the expected SAF file URI",
);
test.assert(
!Url.areSame(folderUrl, joined),
"Folder URL and joined file URL should not be considered the same",
);
}

export async function runUrlTests(writeOutput) {
const runner = new TestRunner("URL / SAF URIs");

for (const joinCase of JOIN_CASES) {
runner.test(joinCase.name, (test) => {
assertJoinCase(test, joinCase);
});
}

for (const trailingSlashCase of TRAILING_SLASH_CASES) {
runner.test(trailingSlashCase.name, (test) => {
test.assert(
Url.areSame(trailingSlashCase.a, trailingSlashCase.b),
"Folder URLs differing only by a trailing slash should be same",
);
});
}

runner.test("Android SAF leading slash", (test) => {
assertJoinCase(test, {
...JOIN_CASES[0],
segment: "/index.html",
});
});

return await runner.run(writeOutput);
}
17 changes: 16 additions & 1 deletion src/utils/Url.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
if (pathnames[1].startsWith("/")) pathnames[1] = pathnames[1].slice(1);
const contentUri = Uri.parse(url);
let [root, pathname] = contentUri.docId.split(":");
const newDocId = path.join(pathname, ...pathnames.slice(1));
let newDocId = path.join(pathname, ...pathnames.slice(1));
if (/^content:\/\/com.termux/.test(url)) {
const rootCondition = root.endsWith("/");
const newDocIdCondition = newDocId.startsWith("/");
Expand All @@ -87,6 +87,21 @@ export default {
}
return `${contentUri.rootUri}::${root}${newDocId}${query}`;
}

// if pathname is undefined, meaning a docId/volume (e.g :primary:)
// has not been detected, so no newDocId's ":" will be added.
if (!pathname) {
// Ensure proper path separator between root and newDocId
let separator = "";
if (root.endsWith("/") && newDocId.startsWith("/")) {
// Both have separator, strip one from newDocId
newDocId = newDocId.slice(1);
} else if (!root.endsWith("/") && !newDocId.startsWith("/")) {
// Neither has separator, add one
separator = "/";
}
return `${contentUri.rootUri}::${root}${separator}${newDocId}${query}`;
}
return `${contentUri.rootUri}::${root}:${newDocId}${query}`;
} catch (error) {
return null;
Expand Down