MCPcopy Create free account
hub / github.com/modem-dev/hunk / buildEditorCommand

Function buildEditorCommand

src/ui/lib/openInEditor.ts:51–72  ·  view source on GitHub ↗
({
  editor,
  filePath,
  line,
}: {
  editor: string;
  filePath: string;
  line: number;
})

Source from the content-addressed store, hash-verified

49
50/** Build an editor process invocation without shell quoting so paths stay cross-platform. */
51export function buildEditorCommand({
52 editor,
53 filePath,
54 line,
55}: {
56 editor: string;
57 filePath: string;
58 line: number;
59}): EditorCommand {
60 const [command = "", ...editorArgs] = splitEditorCommand(editor);
61 const program = editorProgram(editor);
62
63 if (VI_STYLE_EDITORS.includes(program)) {
64 return { command, args: [...editorArgs, `+${line}`, filePath] };
65 }
66
67 if (CODE_STYLE_EDITORS.includes(program)) {
68 return { command, args: [...editorArgs, "--goto", `${filePath}:${line}`] };
69 }
70
71 return { command, args: [...editorArgs, filePath] };
72}
73
74/** Resolve diff paths relative to their source repo instead of the launch cwd. */
75export function resolveEditableFilePath(filePath: string, basePath = process.cwd()) {

Callers 2

openSelectedFileInEditorFunction · 0.85

Calls 2

splitEditorCommandFunction · 0.85
editorProgramFunction · 0.85

Tested by

no test coverage detected