mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 19:14:32 +02:00
BUGFIX: Fix tab completion for multi-word quoted autocomplete options (#2612)
This commit is contained in:
@@ -6,7 +6,7 @@ import { Paper, Popper, TextField, Typography } from "@mui/material";
|
||||
import { KEY } from "../../utils/KeyboardEventKey";
|
||||
import { Terminal } from "../../Terminal";
|
||||
import { Player } from "@player";
|
||||
import { getTabCompletionPossibilities } from "../getTabCompletionPossibilities";
|
||||
import { extractCurrentText, getTabCompletionPossibilities } from "../getTabCompletionPossibilities";
|
||||
import { Settings } from "../../Settings/Settings";
|
||||
import { longestCommonStart } from "../../utils/StringHelperFunctions";
|
||||
import { exceptionAlert } from "../../utils/helpers/exceptionAlert";
|
||||
@@ -266,13 +266,16 @@ export function TerminalInput(): React.ReactElement {
|
||||
if (possibilities.length === 0) return;
|
||||
|
||||
setSearchResults([]);
|
||||
// Use quote-aware replacement: if mid-quote, replace from the opening quote
|
||||
const currentText = extractCurrentText(value);
|
||||
const replacePattern = currentText.startsWith('"') ? /"[^"]*$/ : /[^ ]*$/;
|
||||
if (possibilities.length === 1) {
|
||||
saveValue(value.replace(/[^ ]*$/, possibilities[0]) + " ");
|
||||
saveValue(value.replace(replacePattern, possibilities[0]) + " ");
|
||||
return;
|
||||
}
|
||||
// More than one possibility, check to see if there is a longer common string than currentText.
|
||||
const longestMatch = longestCommonStart(possibilities);
|
||||
saveValue(value.replace(/[^ ]*$/, longestMatch));
|
||||
saveValue(value.replace(replacePattern, longestMatch));
|
||||
setPossibilities(possibilities);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user