From f7ed1ba60a25bd124822e5c33c38032b3c9bc76c Mon Sep 17 00:00:00 2001 From: Huliiiii <134658521+Huliiiiii@users.noreply.github.com> Date: Mon, 8 Sep 2025 19:30:14 +0800 Subject: [PATCH 1/6] Add space menu --- extensions/helix/package.build.ts | 135 +++++++++++++++++++++++++++++ extensions/helix/package.json | 139 ++++++++++++++++++++++++++++++ 2 files changed, 274 insertions(+) diff --git a/extensions/helix/package.build.ts b/extensions/helix/package.build.ts index 41eceaac..1cb405ed 100644 --- a/extensions/helix/package.build.ts +++ b/extensions/helix/package.build.ts @@ -274,6 +274,141 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ }, }, }, + + "space": { + title: "Space", + items: { + "f": { text: "Open file picker", command: "workbench.action.quickOpen" }, + "F": { + text: "Open file picker at current working directory", + command: "dance.run", + args: [ + { + code: [ + "const editor = vscode.window.activeTextEditor;", + "if (!editor) { return; }", + "const currentFileUri = editor.document.uri;", + "", + "const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');", + "", + "const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);", + "if (workspaceFolder) {", + "", + " const relativeDirectoryPath = vscode.workspace.asRelativePath(currentDirectoryUri);", + "", + " const quickOpenPrefix = relativeDirectoryPath.endsWith('/')", + " ? relativeDirectoryPath", + " : `${relativeDirectoryPath}/`;", + "", + " await vscode.commands.executeCommand(", + " 'workbench.action.quickOpen',", + " quickOpenPrefix", + " );", + "} else {", + " await vscode.commands.executeCommand(", + " 'workbench.action.quickOpen'", + " );", + "}", + ], + }, + ], + }, + "b": { + text: "Open buffer picker", + command: "workbench.action.showAllEditors", + }, + "s": { + text: "Open symbol picker", + command: "workbench.action.gotoSymbol", + }, + "S": { + text: "Open workspace symbol picker", + command: "workbench.action.showAllSymbols", + args: [], + }, + "d": { + text: "Open diagnostic picker", + command: "workbench.action.problems.focus", + }, + "D": { + text: "Open diagnostic picker", + command: "workbench.action.problems.focus", + }, + "g": { + text: "Open changed file picker", + command: "workbench.view.scm", + }, + "a": { + text: "Perform code action", + command: "editor.action.quickFix", + }, + "G": { + text: "Debug", + command: "workbench.action.debug.start", + }, + "w": { + text: "Window", + command: "dance.window.windowMenu", + }, + "y": { + text: "Yank selections to clipboard", + command: "dance.selections.saveText", + args: [{ + register: "", + }], + }, + "Y": { + text: "Yank main selection to clipboard", + command: "dance.selections.saveText", + args: [{ + register: "", + }], + }, + "p": { + text: "Paste clipboard after selections", + command: "dance.edit.insert", + args: [{ + handleNewLine: true, + where: "end", + }], + }, + // The following comment was left by https://github.com/Silverquark + // Not sure if it’s still needed. + // + // There is a zero width space (U+200B) behind the P. + // This is a dirty hack. Otherwise vscode will think its the same as lowecase p + // Any other symbol would also work, but this one is invisible + "P​": { + text: "Paste clipboard before selections", + command: "dance.edit.insert", + args: [{ + handleNewLine: true, + where: "start", + }], + }, + "R": { + text: "Replace selections by clipborad content", + command: "editor.action.clipboardPasteAction", + args: [], + }, + "/": { + text: "Global Search in workspace folder", + command: "workbench.action.findInFiles", + }, + "k": { + text: "Show docs for item under cursor (hover)", + command: "editor.action.showHover", + }, + "r": { + text: "Rename symbol", + command: "editor.action.rename", + }, + "h": { + text: "Select symbol reference", + command: "editor.action.referenceSearch.trigger", + }, + }, + }, }, }, diff --git a/extensions/helix/package.json b/extensions/helix/package.json index 8ab52b5c..83312458 100644 --- a/extensions/helix/package.json +++ b/extensions/helix/package.json @@ -1191,6 +1191,145 @@ ] } } + }, + "space": { + "title": "Space", + "items": { + "f": { + "text": "Open file picker", + "command": "workbench.action.quickOpen" + }, + "F": { + "text": "Open file picker at current working directory", + "command": "dance.run", + "args": [ + { + "code": [ + "const editor = vscode.window.activeTextEditor;", + "if (!editor) { return; }", + "const currentFileUri = editor.document.uri;", + "", + "const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');", + "", + "const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);", + "if (workspaceFolder) {", + "", + " const relativeDirectoryPath = vscode.workspace.asRelativePath(currentDirectoryUri);", + "", + " const quickOpenPrefix = relativeDirectoryPath.endsWith('/')", + " ? relativeDirectoryPath", + " : `${relativeDirectoryPath}/`;", + "", + " await vscode.commands.executeCommand(", + " 'workbench.action.quickOpen',", + " quickOpenPrefix", + " );", + "} else {", + " await vscode.commands.executeCommand(", + " 'workbench.action.quickOpen'", + " );", + "}" + ] + } + ] + }, + "b": { + "text": "Open buffer picker", + "command": "workbench.action.showAllEditors" + }, + "s": { + "text": "Open symbol picker", + "command": "workbench.action.gotoSymbol" + }, + "S": { + "text": "Open workspace symbol picker", + "command": "workbench.action.showAllSymbols", + "args": [] + }, + "d": { + "text": "Open diagnostic picker", + "command": "workbench.action.problems.focus" + }, + "D": { + "text": "Open diagnostic picker", + "command": "workbench.action.problems.focus" + }, + "g": { + "text": "Open changed file picker", + "command": "workbench.view.scm" + }, + "a": { + "text": "Perform code action", + "command": "editor.action.quickFix" + }, + "G": { + "text": "Debug", + "command": "workbench.action.debug.start" + }, + "w": { + "text": "Window", + "command": "dance.window.windowMenu" + }, + "y": { + "text": "Yank selections to clipboard", + "command": "dance.selections.saveText", + "args": [ + { + "register": "" + } + ] + }, + "Y": { + "text": "Yank main selection to clipboard", + "command": "dance.selections.saveText", + "args": [ + { + "register": "" + } + ] + }, + "p": { + "text": "Paste clipboard after selections", + "command": "dance.edit.insert", + "args": [ + { + "handleNewLine": true, + "where": "end" + } + ] + }, + "P​": { + "text": "Paste clipboard before selections", + "command": "dance.edit.insert", + "args": [ + { + "handleNewLine": true, + "where": "start" + } + ] + }, + "R": { + "text": "Replace selections by clipborad content", + "command": "editor.action.clipboardPasteAction", + "args": [] + }, + "/": { + "text": "Global Search in workspace folder", + "command": "workbench.action.findInFiles" + }, + "k": { + "text": "Show docs for item under cursor (hover)", + "command": "editor.action.showHover" + }, + "r": { + "text": "Rename symbol", + "command": "editor.action.rename" + }, + "h": { + "text": "Select symbol reference", + "command": "editor.action.referenceSearch.trigger" + } + } } } }, From 3fb0bcc5423e5af216f8cf20198161b934197ac0 Mon Sep 17 00:00:00 2001 From: Huliiiii <134658521+Huliiiiii@users.noreply.github.com> Date: Mon, 8 Sep 2025 20:06:59 +0800 Subject: [PATCH 2/6] Add window menu Copied from Silverquark's fork --- extensions/helix/package.build.ts | 134 ++++++++++++++++++++++++------ extensions/helix/package.json | 93 +++++++++++++++------ 2 files changed, 177 insertions(+), 50 deletions(-) diff --git a/extensions/helix/package.build.ts b/extensions/helix/package.build.ts index 1cb405ed..df04ef66 100644 --- a/extensions/helix/package.build.ts +++ b/extensions/helix/package.build.ts @@ -285,30 +285,39 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ args: [ { code: [ - "const editor = vscode.window.activeTextEditor;", - "if (!editor) { return; }", - "const currentFileUri = editor.document.uri;", - "", - "const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');", - "", - "const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);", - "if (workspaceFolder) {", - "", - " const relativeDirectoryPath = vscode.workspace.asRelativePath(currentDirectoryUri);", - "", - " const quickOpenPrefix = relativeDirectoryPath.endsWith('/')", - " ? relativeDirectoryPath", - " : `${relativeDirectoryPath}/`;", - "", - " await vscode.commands.executeCommand(", - " 'workbench.action.quickOpen',", - " quickOpenPrefix", - " );", - "} else {", - " await vscode.commands.executeCommand(", - " 'workbench.action.quickOpen'", - " );", - "}", + ` + const editor = vscode.window.activeTextEditor; + const fallback = () => vscode.commands.executeCommand( + 'workbench.action.quickOpen', + ); + + if (!editor) { + return await fallback(); + } + + const currentFileUri = editor.document.uri; + const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..'); + + const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri); + if (!workspaceFolder) { + return await fallback() + } + + const relativeDirectoryPath = vscode.workspace.asRelativePath( + currentDirectoryUri, + false + ); + + const quickOpenPrefix = relativeDirectoryPath.endsWith('/') + ? relativeDirectoryPath + : \`\${relativeDirectoryPath}/\`; + + await vscode.commands.executeCommand( + 'workbench.action.quickOpen', + quickOpenPrefix + ); + + `.split("\n").map(line => line.trim()).join(""), ], }, ], @@ -348,7 +357,8 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ }, "w": { text: "Window", - command: "dance.window.windowMenu", + command: "dance.openMenu", + args: [{ menu: "window" }], }, "y": { text: "Yank selections to clipboard", @@ -408,6 +418,80 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ command: "editor.action.referenceSearch.trigger", }, }, + + "window": { + title: "Window", + items: { + "w": { + text: "Goto next window", + command: "workbench.action.nextEditor", + }, + "s": { + text: "Horizontal bottom split", + command: "workbench.action.splitEditorDown", + }, + "v": { + text: "Vertical right split", + command: "workbench.action.splitEditor", + }, + "t": { + text: "Transpose splits", + command: "workbench.action.toggleEditorGroupLayout", + }, + // "f": { + // text: "Open files in selection (hsplit)", + // command: "dance.selections.open", function needs to be modified + // }, + // "F": { + // text: "Open files in selection (vsplit)", + // command: "dance.selections.open", function needs to be modified + // }, + "q": { + text: "Close window", + command: "workbench.action.closeActiveEditor", + }, + "o": { + text: "Close all other windows (Current window only)", + command: "workbench.action.closeOtherEditors", + }, + "h": { + text: "Jump to the split on the left", + command: "workbench.action.focusLeftGroup", + }, + "j": { + text: "Jump to the split below", + command: "workbench.action.focusBelowGroup", + }, + "k": { + text: "Jump to the split above", + command: "workbench.action.focusAboveGroup", + }, + "l": { + text: "Jump to the split to the right", + command: "workbench.action.focusRightGroup", + }, + "H": { + text: "Swap with the split to the left", + command: "workbench.action.moveActiveEditorGroupLeft", + }, + "J": { + text: "Swap with the split below", + command: "workbench.action.moveActiveEditorGroupDown", + }, + "K": { + text: "Swap with the split above", + command: "workbench.action.moveActiveEditorGroupUp", + }, + "L": { + text: "Swap with the split to the right", + command: "workbench.action.moveActiveEditorGroupRight", + }, + // "n": { Not easily possible. Neccessary? + // text: "New split scratch buffer", + // command: "", + // }, + }, + }, }, }, }, diff --git a/extensions/helix/package.json b/extensions/helix/package.json index 83312458..e3244d73 100644 --- a/extensions/helix/package.json +++ b/extensions/helix/package.json @@ -1205,30 +1205,7 @@ "args": [ { "code": [ - "const editor = vscode.window.activeTextEditor;", - "if (!editor) { return; }", - "const currentFileUri = editor.document.uri;", - "", - "const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');", - "", - "const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);", - "if (workspaceFolder) {", - "", - " const relativeDirectoryPath = vscode.workspace.asRelativePath(currentDirectoryUri);", - "", - " const quickOpenPrefix = relativeDirectoryPath.endsWith('/')", - " ? relativeDirectoryPath", - " : `${relativeDirectoryPath}/`;", - "", - " await vscode.commands.executeCommand(", - " 'workbench.action.quickOpen',", - " quickOpenPrefix", - " );", - "} else {", - " await vscode.commands.executeCommand(", - " 'workbench.action.quickOpen'", - " );", - "}" + "const editor = vscode.window.activeTextEditor;const fallback = () => vscode.commands.executeCommand('workbench.action.quickOpen',);if (!editor) {return await fallback();}const currentFileUri = editor.document.uri;const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);if (!workspaceFolder) {return await fallback()}const relativeDirectoryPath = vscode.workspace.asRelativePath(currentDirectoryUri,false);const quickOpenPrefix = relativeDirectoryPath.endsWith('/')? relativeDirectoryPath: `${relativeDirectoryPath}/`;await vscode.commands.executeCommand('workbench.action.quickOpen',quickOpenPrefix);" ] } ] @@ -1268,7 +1245,12 @@ }, "w": { "text": "Window", - "command": "dance.window.windowMenu" + "command": "dance.openMenu", + "args": [ + { + "menu": "window" + } + ] }, "y": { "text": "Yank selections to clipboard", @@ -1329,6 +1311,67 @@ "text": "Select symbol reference", "command": "editor.action.referenceSearch.trigger" } + }, + "window": { + "title": "Window", + "items": { + "w": { + "text": "Goto next window", + "command": "workbench.action.nextEditor" + }, + "s": { + "text": "Horizontal bottom split", + "command": "workbench.action.splitEditorDown" + }, + "v": { + "text": "Vertical right split", + "command": "workbench.action.splitEditor" + }, + "t": { + "text": "Transpose splits", + "command": "workbench.action.toggleEditorGroupLayout" + }, + "q": { + "text": "Close window", + "command": "workbench.action.closeActiveEditor" + }, + "o": { + "text": "Close all other windows (Current window only)", + "command": "workbench.action.closeOtherEditors" + }, + "h": { + "text": "Jump to the split on the left", + "command": "workbench.action.focusLeftGroup" + }, + "j": { + "text": "Jump to the split below", + "command": "workbench.action.focusBelowGroup" + }, + "k": { + "text": "Jump to the split above", + "command": "workbench.action.focusAboveGroup" + }, + "l": { + "text": "Jump to the split to the right", + "command": "workbench.action.focusRightGroup" + }, + "H": { + "text": "Swap with the split to the left", + "command": "workbench.action.moveActiveEditorGroupLeft" + }, + "J": { + "text": "Swap with the split below", + "command": "workbench.action.moveActiveEditorGroupDown" + }, + "K": { + "text": "Swap with the split above", + "command": "workbench.action.moveActiveEditorGroupUp" + }, + "L": { + "text": "Swap with the split to the right", + "command": "workbench.action.moveActiveEditorGroupRight" + } + } } } } From c85108a55cca474591e3b8317bca26477ed0118a Mon Sep 17 00:00:00 2001 From: Huliiiii <134658521+Huliiiiii@users.noreply.github.com> Date: Tue, 9 Sep 2025 20:39:44 +0800 Subject: [PATCH 3/6] Update --- extensions/helix/package.build.ts | 97 ++++++++++++++++--------------- extensions/helix/package.json | 41 +++++++++++-- 2 files changed, 86 insertions(+), 52 deletions(-) diff --git a/extensions/helix/package.build.ts b/extensions/helix/package.build.ts index df04ef66..debe4c8b 100644 --- a/extensions/helix/package.build.ts +++ b/extensions/helix/package.build.ts @@ -275,7 +275,7 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ }, }, - "space": { + space: { title: "Space", items: { "f": { text: "Open file picker", command: "workbench.action.quickOpen" }, @@ -285,39 +285,36 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ args: [ { code: [ - ` - const editor = vscode.window.activeTextEditor; - const fallback = () => vscode.commands.executeCommand( - 'workbench.action.quickOpen', - ); - - if (!editor) { - return await fallback(); - } - - const currentFileUri = editor.document.uri; - const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..'); - - const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri); - if (!workspaceFolder) { - return await fallback() - } - - const relativeDirectoryPath = vscode.workspace.asRelativePath( - currentDirectoryUri, - false - ); - - const quickOpenPrefix = relativeDirectoryPath.endsWith('/') - ? relativeDirectoryPath - : \`\${relativeDirectoryPath}/\`; - - await vscode.commands.executeCommand( - 'workbench.action.quickOpen', - quickOpenPrefix - ); - - `.split("\n").map(line => line.trim()).join(""), + "const fallback = () => vscode.commands.executeCommand(", + " 'workbench.action.quickOpen',", + " );", + + "const editor = vscode.window.activeTextEditor;", + "if (!editor) {", + " return await fallback();", + "}", + + "const currentFileUri = editor.document.uri;", + "const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');", + + "const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);", + "if (!workspaceFolder) {", + " return await fallback()", + "}", + + "const relativeDirectoryPath = vscode.workspace.asRelativePath(", + " currentDirectoryUri,", + " /** includeWorkspaceFolder = */ false", + " );", + + "const quickOpenPrefix = relativeDirectoryPath.endsWith('/')", + " ? relativeDirectoryPath", + " : relativeDirectoryPath + '/';", + + "await vscode.commands.executeCommand(", + " 'workbench.action.quickOpen',", + " quickOpenPrefix,", + ");", ], }, ], @@ -326,6 +323,10 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ text: "Open buffer picker", command: "workbench.action.showAllEditors", }, + // "j": { + // text: "Open jumplist picker", + // command: "", // TODO + // }, "s": { text: "Open symbol picker", command: "workbench.action.gotoSymbol", @@ -333,7 +334,6 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ "S": { text: "Open workspace symbol picker", command: "workbench.action.showAllSymbols", - args: [], }, "d": { text: "Open diagnostic picker", @@ -351,6 +351,10 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ text: "Perform code action", command: "editor.action.quickFix", }, + // "'": { + // text: "Open last picker", + // command: "", // TODO + // }, "G": { text: "Debug", command: "workbench.action.debug.start", @@ -369,9 +373,16 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ }, "Y": { text: "Yank main selection to clipboard", - command: "dance.selections.saveText", + command: "dance.run", args: [{ - register: "", + code: [ + "const editor = vscode.window.activeTextEditor;", + "if (!editor) {", + " return;", + "}", + "const text = editor.document.getText(editor.selection);", + "await vscode.env.clipboard.writeText(text);", + ], }], }, "p": { @@ -382,13 +393,7 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ where: "end", }], }, - // The following comment was left by https://github.com/Silverquark - // Not sure if it’s still needed. - // - // There is a zero width space (U+200B) behind the P. - // This is a dirty hack. Otherwise vscode will think its the same as lowecase p - // Any other symbol would also work, but this one is invisible - "P​": { + "P": { text: "Paste clipboard before selections", command: "dance.edit.insert", args: [{ @@ -440,11 +445,11 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ }, // "f": { // text: "Open files in selection (hsplit)", - // command: "dance.selections.open", function needs to be modified + // command: "dance.selections.open", // function needs to be modified // }, // "F": { // text: "Open files in selection (vsplit)", - // command: "dance.selections.open", function needs to be modified + // command: "dance.selections.open", // function needs to be modified // }, "q": { text: "Close window", diff --git a/extensions/helix/package.json b/extensions/helix/package.json index e3244d73..0e226e6f 100644 --- a/extensions/helix/package.json +++ b/extensions/helix/package.json @@ -1205,7 +1205,30 @@ "args": [ { "code": [ - "const editor = vscode.window.activeTextEditor;const fallback = () => vscode.commands.executeCommand('workbench.action.quickOpen',);if (!editor) {return await fallback();}const currentFileUri = editor.document.uri;const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);if (!workspaceFolder) {return await fallback()}const relativeDirectoryPath = vscode.workspace.asRelativePath(currentDirectoryUri,false);const quickOpenPrefix = relativeDirectoryPath.endsWith('/')? relativeDirectoryPath: `${relativeDirectoryPath}/`;await vscode.commands.executeCommand('workbench.action.quickOpen',quickOpenPrefix);" + "const fallback = () => vscode.commands.executeCommand(", + " 'workbench.action.quickOpen',", + " );", + "const editor = vscode.window.activeTextEditor;", + "if (!editor) {", + " return await fallback();", + "}", + "const currentFileUri = editor.document.uri;", + "const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');", + "const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);", + "if (!workspaceFolder) {", + " return await fallback()", + "}", + "const relativeDirectoryPath = vscode.workspace.asRelativePath(", + " currentDirectoryUri,", + " /** includeWorkspaceFolder = */ false", + " );", + "const quickOpenPrefix = relativeDirectoryPath.endsWith('/')", + " ? relativeDirectoryPath", + " : relativeDirectoryPath + '/';", + "await vscode.commands.executeCommand(", + " 'workbench.action.quickOpen',", + " quickOpenPrefix,", + ");" ] } ] @@ -1220,8 +1243,7 @@ }, "S": { "text": "Open workspace symbol picker", - "command": "workbench.action.showAllSymbols", - "args": [] + "command": "workbench.action.showAllSymbols" }, "d": { "text": "Open diagnostic picker", @@ -1263,10 +1285,17 @@ }, "Y": { "text": "Yank main selection to clipboard", - "command": "dance.selections.saveText", + "command": "dance.run", "args": [ { - "register": "" + "code": [ + "const editor = vscode.window.activeTextEditor;", + "if (!editor) {", + " return;", + "}", + "const text = editor.document.getText(editor.selection);", + "await vscode.env.clipboard.writeText(text);" + ] } ] }, @@ -1280,7 +1309,7 @@ } ] }, - "P​": { + "P": { "text": "Paste clipboard before selections", "command": "dance.edit.insert", "args": [ From 34aba06e11f4a7d9490eb37fd41ee88564487143 Mon Sep 17 00:00:00 2001 From: Huliiiii <134658521+Huliiiiii@users.noreply.github.com> Date: Mon, 22 Sep 2025 07:09:42 +0800 Subject: [PATCH 4/6] Update - Add ES2021.String to lib because replaceAll requires it --- extensions/helix/package.build.ts | 207 +++++++++++++++--------------- extensions/helix/package.json | 140 ++++++++++---------- tsconfig.json | 2 +- 3 files changed, 173 insertions(+), 176 deletions(-) diff --git a/extensions/helix/package.build.ts b/extensions/helix/package.build.ts index debe4c8b..f5e6373d 100644 --- a/extensions/helix/package.build.ts +++ b/extensions/helix/package.build.ts @@ -284,38 +284,34 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ command: "dance.run", args: [ { - code: [ - "const fallback = () => vscode.commands.executeCommand(", - " 'workbench.action.quickOpen',", - " );", - - "const editor = vscode.window.activeTextEditor;", - "if (!editor) {", - " return await fallback();", - "}", - - "const currentFileUri = editor.document.uri;", - "const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');", - - "const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);", - "if (!workspaceFolder) {", - " return await fallback()", - "}", - - "const relativeDirectoryPath = vscode.workspace.asRelativePath(", - " currentDirectoryUri,", - " /** includeWorkspaceFolder = */ false", - " );", - - "const quickOpenPrefix = relativeDirectoryPath.endsWith('/')", - " ? relativeDirectoryPath", - " : relativeDirectoryPath + '/';", - - "await vscode.commands.executeCommand(", - " 'workbench.action.quickOpen',", - " quickOpenPrefix,", - ");", - ], + code: + `const fallback = () => vscode.commands.executeCommand( + 'workbench.action.quickOpen', + ); + const editor = vscode.window.activeTextEditor; + if (!editor) { + return await fallback(); + } + const currentFileUri = editor.document.uri; + const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..'); + const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri); + if (!workspaceFolder) { + return await fallback(); + } + const relativeDirectoryPath = vscode.workspace.asRelativePath( + currentDirectoryUri, + /** includeWorkspaceFolder = */ false + ); + const quickOpenPrefix = relativeDirectoryPath.endsWith('/') ? relativeDirectoryPath : relativeDirectoryPath + "/"; + await vscode.commands.executeCommand( + 'workbench.action.quickOpen', + quickOpenPrefix, + );` + // The indentation of multi-line template strings + .replaceAll(" ", "") + .replaceAll(/^ {,2}/mg, "") + .split("\n") + , }, ], }, @@ -389,6 +385,7 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ text: "Paste clipboard after selections", command: "dance.edit.insert", args: [{ + register: "", handleNewLine: true, where: "end", }], @@ -397,12 +394,13 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ text: "Paste clipboard before selections", command: "dance.edit.insert", args: [{ + register: "", handleNewLine: true, where: "start", }], }, "R": { - text: "Replace selections by clipborad content", + text: "Replace selections by clipboard content", command: "editor.action.clipboardPasteAction", args: [], }, @@ -423,79 +421,78 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ command: "editor.action.referenceSearch.trigger", }, }, - - "window": { - title: "Window", - items: { - "w": { - text: "Goto next window", - command: "workbench.action.nextEditor", - }, - "s": { - text: "Horizontal bottom split", - command: "workbench.action.splitEditorDown", - }, - "v": { - text: "Vertical right split", - command: "workbench.action.splitEditor", - }, - "t": { - text: "Transpose splits", - command: "workbench.action.toggleEditorGroupLayout", - }, - // "f": { - // text: "Open files in selection (hsplit)", - // command: "dance.selections.open", // function needs to be modified - // }, - // "F": { - // text: "Open files in selection (vsplit)", - // command: "dance.selections.open", // function needs to be modified - // }, - "q": { - text: "Close window", - command: "workbench.action.closeActiveEditor", - }, - "o": { - text: "Close all other windows (Current window only)", - command: "workbench.action.closeOtherEditors", - }, - "h": { - text: "Jump to the split on the left", - command: "workbench.action.focusLeftGroup", - }, - "j": { - text: "Jump to the split below", - command: "workbench.action.focusBelowGroup", - }, - "k": { - text: "Jump to the split above", - command: "workbench.action.focusAboveGroup", - }, - "l": { - text: "Jump to the split to the right", - command: "workbench.action.focusRightGroup", - }, - "H": { - text: "Swap with the split to the left", - command: "workbench.action.moveActiveEditorGroupLeft", - }, - "J": { - text: "Swap with the split below", - command: "workbench.action.moveActiveEditorGroupDown", - }, - "K": { - text: "Swap with the split above", - command: "workbench.action.moveActiveEditorGroupUp", - }, - "L": { - text: "Swap with the split to the right", - command: "workbench.action.moveActiveEditorGroupRight", - }, - // "n": { Not easily possible. Neccessary? - // text: "New split scratch buffer", - // command: "", - // }, + }, + window: { + title: "Window", + items: { + "w": { + text: "Goto next window", + command: "workbench.action.nextEditor", + }, + "s": { + text: "Horizontal bottom split", + command: "workbench.action.splitEditorDown", + }, + "v": { + text: "Vertical right split", + command: "workbench.action.splitEditor", + }, + "t": { + text: "Transpose splits", + command: "workbench.action.toggleEditorGroupLayout", + }, + // "f": { + // text: "Open files in selection (hsplit)", + // command: "dance.selections.open", // function needs to be modified + // }, + // "F": { + // text: "Open files in selection (vsplit)", + // command: "dance.selections.open", // function needs to be modified + // }, + "q": { + text: "Close window", + command: "workbench.action.closeActiveEditor", + }, + "o": { + text: "Close windows except current", + command: "workbench.action.closeOtherEditors", + }, + "h": { + text: "Jump to the split on the left", + command: "workbench.action.focusLeftGroup", + }, + "j": { + text: "Jump to the split below", + command: "workbench.action.focusBelowGroup", + }, + "k": { + text: "Jump to the split above", + command: "workbench.action.focusAboveGroup", + }, + "l": { + text: "Jump to the split to the right", + command: "workbench.action.focusRightGroup", }, + "H": { + text: "Swap with the split to the left", + command: "workbench.action.moveActiveEditorGroupLeft", + }, + "J": { + text: "Swap with the split below", + command: "workbench.action.moveActiveEditorGroupDown", + }, + "K": { + text: "Swap with the split above", + command: "workbench.action.moveActiveEditorGroupUp", + }, + "L": { + text: "Swap with the split to the right", + command: "workbench.action.moveActiveEditorGroupRight", + }, + // "n": { Not easily possible. Necessary? + // text: "New split scratch buffer", + // command: "", + // }, }, }, }, diff --git a/extensions/helix/package.json b/extensions/helix/package.json index 0e226e6f..80fbe305 100644 --- a/extensions/helix/package.json +++ b/extensions/helix/package.json @@ -1206,8 +1206,8 @@ { "code": [ "const fallback = () => vscode.commands.executeCommand(", - " 'workbench.action.quickOpen',", - " );", + " 'workbench.action.quickOpen',", + ");", "const editor = vscode.window.activeTextEditor;", "if (!editor) {", " return await fallback();", @@ -1216,15 +1216,13 @@ "const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');", "const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);", "if (!workspaceFolder) {", - " return await fallback()", + " return await fallback();", "}", "const relativeDirectoryPath = vscode.workspace.asRelativePath(", - " currentDirectoryUri,", - " /** includeWorkspaceFolder = */ false", - " );", - "const quickOpenPrefix = relativeDirectoryPath.endsWith('/')", - " ? relativeDirectoryPath", - " : relativeDirectoryPath + '/';", + " currentDirectoryUri,", + " /** includeWorkspaceFolder = */ false", + ");", + "const quickOpenPrefix = relativeDirectoryPath.endsWith('/') ? relativeDirectoryPath : relativeDirectoryPath + \"/\";", "await vscode.commands.executeCommand(", " 'workbench.action.quickOpen',", " quickOpenPrefix,", @@ -1304,6 +1302,7 @@ "command": "dance.edit.insert", "args": [ { + "register": "", "handleNewLine": true, "where": "end" } @@ -1314,13 +1313,14 @@ "command": "dance.edit.insert", "args": [ { + "register": "", "handleNewLine": true, "where": "start" } ] }, "R": { - "text": "Replace selections by clipborad content", + "text": "Replace selections by clipboard content", "command": "editor.action.clipboardPasteAction", "args": [] }, @@ -1340,66 +1340,66 @@ "text": "Select symbol reference", "command": "editor.action.referenceSearch.trigger" } - }, - "window": { - "title": "Window", - "items": { - "w": { - "text": "Goto next window", - "command": "workbench.action.nextEditor" - }, - "s": { - "text": "Horizontal bottom split", - "command": "workbench.action.splitEditorDown" - }, - "v": { - "text": "Vertical right split", - "command": "workbench.action.splitEditor" - }, - "t": { - "text": "Transpose splits", - "command": "workbench.action.toggleEditorGroupLayout" - }, - "q": { - "text": "Close window", - "command": "workbench.action.closeActiveEditor" - }, - "o": { - "text": "Close all other windows (Current window only)", - "command": "workbench.action.closeOtherEditors" - }, - "h": { - "text": "Jump to the split on the left", - "command": "workbench.action.focusLeftGroup" - }, - "j": { - "text": "Jump to the split below", - "command": "workbench.action.focusBelowGroup" - }, - "k": { - "text": "Jump to the split above", - "command": "workbench.action.focusAboveGroup" - }, - "l": { - "text": "Jump to the split to the right", - "command": "workbench.action.focusRightGroup" - }, - "H": { - "text": "Swap with the split to the left", - "command": "workbench.action.moveActiveEditorGroupLeft" - }, - "J": { - "text": "Swap with the split below", - "command": "workbench.action.moveActiveEditorGroupDown" - }, - "K": { - "text": "Swap with the split above", - "command": "workbench.action.moveActiveEditorGroupUp" - }, - "L": { - "text": "Swap with the split to the right", - "command": "workbench.action.moveActiveEditorGroupRight" - } + } + }, + "window": { + "title": "Window", + "items": { + "w": { + "text": "Goto next window", + "command": "workbench.action.nextEditor" + }, + "s": { + "text": "Horizontal bottom split", + "command": "workbench.action.splitEditorDown" + }, + "v": { + "text": "Vertical right split", + "command": "workbench.action.splitEditor" + }, + "t": { + "text": "Transpose splits", + "command": "workbench.action.toggleEditorGroupLayout" + }, + "q": { + "text": "Close window", + "command": "workbench.action.closeActiveEditor" + }, + "o": { + "text": "Close windows except current", + "command": "workbench.action.closeOtherEditors" + }, + "h": { + "text": "Jump to the split on the left", + "command": "workbench.action.focusLeftGroup" + }, + "j": { + "text": "Jump to the split below", + "command": "workbench.action.focusBelowGroup" + }, + "k": { + "text": "Jump to the split above", + "command": "workbench.action.focusAboveGroup" + }, + "l": { + "text": "Jump to the split to the right", + "command": "workbench.action.focusRightGroup" + }, + "H": { + "text": "Swap with the split to the left", + "command": "workbench.action.moveActiveEditorGroupLeft" + }, + "J": { + "text": "Swap with the split below", + "command": "workbench.action.moveActiveEditorGroupDown" + }, + "K": { + "text": "Swap with the split above", + "command": "workbench.action.moveActiveEditorGroupUp" + }, + "L": { + "text": "Swap with the split to the right", + "command": "workbench.action.moveActiveEditorGroupRight" } } } diff --git a/tsconfig.json b/tsconfig.json index 966e3c30..3377fb95 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "CommonJS", "target": "ES2021", - "lib": ["ESNext.WeakRef"], + "lib": ["ESNext.WeakRef", "ES2021.String"], "noEmit": true, "sourceMap": true, "strict": true, From 25ffcf0f534de8e3e8d49925484eeada83d84e34 Mon Sep 17 00:00:00 2001 From: Huliiiii <134658521+Huliiiiii@users.noreply.github.com> Date: Mon, 22 Sep 2025 07:14:42 +0800 Subject: [PATCH 5/6] Specify register --- extensions/helix/package.build.ts | 6 +++--- extensions/helix/package.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/extensions/helix/package.build.ts b/extensions/helix/package.build.ts index f5e6373d..221ba726 100644 --- a/extensions/helix/package.build.ts +++ b/extensions/helix/package.build.ts @@ -364,7 +364,7 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ text: "Yank selections to clipboard", command: "dance.selections.saveText", args: [{ - register: "", + register: "dquote", }], }, "Y": { @@ -385,7 +385,7 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ text: "Paste clipboard after selections", command: "dance.edit.insert", args: [{ - register: "", + register: "dquote", handleNewLine: true, where: "end", }], @@ -394,7 +394,7 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ text: "Paste clipboard before selections", command: "dance.edit.insert", args: [{ - register: "", + register: "dquote", handleNewLine: true, where: "start", }], diff --git a/extensions/helix/package.json b/extensions/helix/package.json index 80fbe305..784bfce1 100644 --- a/extensions/helix/package.json +++ b/extensions/helix/package.json @@ -1277,7 +1277,7 @@ "command": "dance.selections.saveText", "args": [ { - "register": "" + "register": "dquote" } ] }, @@ -1302,7 +1302,7 @@ "command": "dance.edit.insert", "args": [ { - "register": "", + "register": "dquote", "handleNewLine": true, "where": "end" } @@ -1313,7 +1313,7 @@ "command": "dance.edit.insert", "args": [ { - "register": "", + "register": "dquote", "handleNewLine": true, "where": "start" } From 3e1f8bfa6d9b1193dfbd8b49e8ca82016e5617bc Mon Sep 17 00:00:00 2001 From: Huliiiii <134658521+Huliiiiii@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:38:47 +0800 Subject: [PATCH 6/6] Fix --- extensions/helix/package.build.ts | 62 ++++++++++++++++++------------- extensions/helix/package.json | 6 ++- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/extensions/helix/package.build.ts b/extensions/helix/package.build.ts index 221ba726..56ed19e7 100644 --- a/extensions/helix/package.build.ts +++ b/extensions/helix/package.build.ts @@ -285,32 +285,42 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ args: [ { code: - `const fallback = () => vscode.commands.executeCommand( - 'workbench.action.quickOpen', - ); - const editor = vscode.window.activeTextEditor; - if (!editor) { - return await fallback(); - } - const currentFileUri = editor.document.uri; - const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..'); - const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri); - if (!workspaceFolder) { - return await fallback(); - } - const relativeDirectoryPath = vscode.workspace.asRelativePath( - currentDirectoryUri, - /** includeWorkspaceFolder = */ false - ); - const quickOpenPrefix = relativeDirectoryPath.endsWith('/') ? relativeDirectoryPath : relativeDirectoryPath + "/"; - await vscode.commands.executeCommand( - 'workbench.action.quickOpen', - quickOpenPrefix, - );` - // The indentation of multi-line template strings - .replaceAll(" ", "") - .replaceAll(/^ {,2}/mg, "") - .split("\n") + (() => { + const codeStr = + `const fallback = () => vscode.commands.executeCommand( + 'workbench.action.quickOpen', + ); + const editor = vscode.window.activeTextEditor; + if (!editor) { + return await fallback(); + } + const currentFileUri = editor.document.uri; + const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..'); + const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri); + if (!workspaceFolder || currentDirectoryUri.fsPath === workspaceFolder.uri.fsPath) { + return await fallback(); + } + const relativeDirectoryPath = vscode.workspace.asRelativePath( + currentDirectoryUri, + /** includeWorkspaceFolder = */ false + ); + const quickOpenPrefix = relativeDirectoryPath.endsWith('/') ? + relativeDirectoryPath + : relativeDirectoryPath + "/"; + await vscode.commands.executeCommand( + 'workbench.action.quickOpen', + quickOpenPrefix, + );`; + + const lines = codeStr.split("\n"); + const theThirdLine = lines[2]; + // Get the indentation of the multi-line template string + const indent = theThirdLine.match(/^([ \t]*)/)![0]; + // Remove the indentation and split into array of lines + return codeStr + .replaceAll(indent, "") + .split("\n"); + })() , }, ], diff --git a/extensions/helix/package.json b/extensions/helix/package.json index 784bfce1..0c8f24f5 100644 --- a/extensions/helix/package.json +++ b/extensions/helix/package.json @@ -1215,14 +1215,16 @@ "const currentFileUri = editor.document.uri;", "const currentDirectoryUri = vscode.Uri.joinPath(currentFileUri, '..');", "const workspaceFolder = vscode.workspace.getWorkspaceFolder(currentFileUri);", - "if (!workspaceFolder) {", + "if (!workspaceFolder || currentDirectoryUri.fsPath === workspaceFolder.uri.fsPath) {", " return await fallback();", "}", "const relativeDirectoryPath = vscode.workspace.asRelativePath(", " currentDirectoryUri,", " /** includeWorkspaceFolder = */ false", ");", - "const quickOpenPrefix = relativeDirectoryPath.endsWith('/') ? relativeDirectoryPath : relativeDirectoryPath + \"/\";", + "const quickOpenPrefix = relativeDirectoryPath.endsWith('/') ?", + " relativeDirectoryPath", + " : relativeDirectoryPath + \"/\";", "await vscode.commands.executeCommand(", " 'workbench.action.quickOpen',", " quickOpenPrefix,",