mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 23:08:36 +02:00
BUGFIX: Fix tab completion for multi-word quoted autocomplete options (#2612)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
|
||||
import { Player } from "../../../src/Player";
|
||||
import { getTabCompletionPossibilities } from "../../../src/Terminal/getTabCompletionPossibilities";
|
||||
import { getTabCompletionPossibilities, extractCurrentText } from "../../../src/Terminal/getTabCompletionPossibilities";
|
||||
import { Server } from "../../../src/Server/Server";
|
||||
import { AddToAllServers, prestigeAllServers } from "../../../src/Server/AllServers";
|
||||
import { LocationName } from "../../../src/Enums";
|
||||
@@ -187,6 +187,27 @@ describe("getTabCompletionPossibilities", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("extractCurrentText", () => {
|
||||
it("returns last word for unquoted input", () => {
|
||||
expect(extractCurrentText("run myscript.js foo")).toBe("foo");
|
||||
});
|
||||
it("returns empty string for input ending with space", () => {
|
||||
expect(extractCurrentText("run myscript.js ")).toBe("");
|
||||
});
|
||||
it("returns text from opening quote for unclosed double quote", () => {
|
||||
expect(extractCurrentText('run myscript.js "nonunique se')).toBe('"nonunique se');
|
||||
});
|
||||
it("returns last word when all quotes are closed", () => {
|
||||
expect(extractCurrentText('run myscript.js "arg1" foo')).toBe("foo");
|
||||
});
|
||||
it("handles empty input", () => {
|
||||
expect(extractCurrentText("")).toBe("");
|
||||
});
|
||||
it("returns text from opening quote with one word inside", () => {
|
||||
expect(extractCurrentText('run "partial')).toBe('"partial');
|
||||
});
|
||||
});
|
||||
|
||||
function asDirectory(dir: string): Directory {
|
||||
if (!isAbsolutePath(dir) || !isDirectoryPath(dir)) throw new Error(`Directory ${dir} failed typechecking`);
|
||||
return dir;
|
||||
|
||||
Reference in New Issue
Block a user