pi-ext
bugabingas pi extensions
owned by bugabinga
fix(the-system): preserve Windows editor paths
7e35e0185427e3599bc7f8b478472756d3213acb
Oliver Krylow <o.krylow@isp-insoft.de> ·
SSH signature · not checked
Browse filesCompare with HEAD
Changed files (2)
extensions/the-system/__tests__/the-system.test.ts
Modified328 328 chmodSync(editor,
0o755);
329 329 const previousVisual
= process.
env.VISUAL;
330 330 const previousEditor
= process.
env.EDITOR;
331 - process.
env.VISUAL
= `${process.execPath} ${JSON.stringify(editor)} ${JSON.stringify(log)}`;
331 + process.
env.VISUAL
= `${JSON.stringify(process.execPath)} ${JSON.stringify(editor)} ${JSON.stringify(log)}`;
332 332 delete process.
env.EDITOR;
334 334 const command
= createSystemCommand({
sendUserMessage() {} }
as never);
359 359 args: [
"--wait",
"two words"],
362 + parseEditorCommand(
363 + '"C:\\Program Files\\Editor\\edit.exe" "C:\\work tree\\file.md"',
366 + command:
"C:\\Program Files\\Editor\\edit.exe",
367 + args: [
"C:\\work tree\\file.md"],
361 370 assert.
deepEqual(
362 371 editorCandidates(
"file.md", { VISUAL:
"v", EDITOR:
"e" },
"linux").
slice(
extensions/the-system/open-editor.ts
Modified 90 90 const parts
: string[]
= [];
92 92 let quote
: "'" | '"' | undefined;
93 - let escaping
= false;
95 - for (
const char
of input) {
94 + for (
let index
= 0; index
< input.
length; index
++) {
95 + const char
= input[index];
101 96 if (char
=== "\\" && quote
!== "'") {
97 + const next
= input[index
+ 1];
98 + if (next
&& (
/\s/.
test(next)
|| next
=== '"' || next
=== "'")) {
105 104 if ((char
=== "'" || char
=== '"')
&& !quote) {
120 - if (escaping) current
+= "\\";
121 119 if (current) parts.
push(current);