Windows: fix cmd quoting, CRLF saves and Neovim's remote output
cmd strips outer quotes when a line starts with one, which broke .cmd editors with spaces in both paths. Neovim on Windows prints remote results to the console, so they ran over the screen and never reached us; give it a hidden console and read results from a file.
This commit is contained in:
1 parent
df2c8e0907
commit
eb5cccece1
3 files changed
+30
-7
No files matched your search
+10
-2
@@ -1,6 +1,7 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { writeFileSync } from "node:fs";
|
||||
|
||||
import { isNvim, windowsCommand, windowsWords } from "../src/ui/editor.ts";
|
||||
import { isNvim, scratchFile, windowsCommand, windowsWords } from "../src/ui/editor.ts";
|
||||
|
||||
test("splits a Windows command line on spaces outside quotes", () => {
|
||||
expect(windowsWords('"C:\\Program Files\\Git\\usr\\bin\\vim.exe" -p')).toEqual(["C:\\Program Files\\Git\\usr\\bin\\vim.exe", "-p"]);
|
||||
@@ -9,7 +10,7 @@ test("splits a Windows command line on spaces outside quotes", () => {
|
||||
|
||||
test("runs a .cmd through cmd, and anything else as it is", () => {
|
||||
const which = (program: string) => ({ code: "C:\\VS Code\\bin\\code.cmd", nvim: "C:\\nvim\\nvim.exe" })[program] ?? null;
|
||||
expect(windowsCommand("code --wait", which)).toEqual(["cmd.exe", "/c", "C:\\VS Code\\bin\\code.cmd", "--wait"]);
|
||||
expect(windowsCommand("code --wait", which)).toEqual(["cmd.exe", "/c", "call", "C:\\VS Code\\bin\\code.cmd", "--wait"]);
|
||||
expect(windowsCommand("nvim", which)).toEqual(["C:\\nvim\\nvim.exe"]);
|
||||
expect(windowsCommand("missing", which)).toEqual(["missing"]);
|
||||
});
|
||||
@@ -20,3 +21,10 @@ test("knows Neovim by name or path", () => {
|
||||
expect(isNvim("C:\\Program Files\\Neovim\\bin\\nvim.exe")).toBe(true);
|
||||
expect(isNvim("vim")).toBe(false);
|
||||
});
|
||||
|
||||
test("reads back a scratch file saved with CRLF", () => {
|
||||
const file = scratchFile("");
|
||||
writeFileSync(file.path, "one\r\ntwo\r\n");
|
||||
expect(file.read()).toBe("one\ntwo");
|
||||
file.remove();
|
||||
});
|
||||
Reference in new issue
Block a user