fix: 🐛 a handful of bug fixes
keyboard interactions in textarea, multiple file highlighting, zombie process
This commit is contained in:
parent
88599cfa69
commit
e1325c0153
4 changed files with 83 additions and 43 deletions
|
|
@ -31,6 +31,7 @@ class HighlightedCodeContextProvider(ContextProvider):
|
|||
last_added_fallback: bool = False
|
||||
|
||||
async def _get_fallback_context_item(self) -> HighlightedRangeContextItem:
|
||||
# Used to automatically include the currently open file. Disabled for now.
|
||||
return None
|
||||
|
||||
if not self.should_get_fallback_context_item:
|
||||
|
|
@ -89,6 +90,7 @@ class HighlightedCodeContextProvider(ContextProvider):
|
|||
name_status[basename] = {hr.rif.filepath}
|
||||
|
||||
for hr in self.highlighted_ranges:
|
||||
basename = os.path.basename(hr.rif.filepath)
|
||||
if len(name_status[basename]) > 1:
|
||||
hr.item.description.name = self._rif_to_name(hr.rif, display_filename=os.path.join(
|
||||
os.path.basename(os.path.dirname(hr.rif.filepath)), basename))
|
||||
|
|
@ -109,13 +111,11 @@ class HighlightedCodeContextProvider(ContextProvider):
|
|||
self.last_added_fallback = False
|
||||
|
||||
async def delete_context_with_ids(self, ids: List[ContextItemId]) -> List[ContextItem]:
|
||||
indices_to_delete = [
|
||||
int(id.item_id) for id in ids
|
||||
]
|
||||
ids_to_delete = [id.item_id for id in ids]
|
||||
|
||||
kept_ranges = []
|
||||
for i, hr in enumerate(self.highlighted_ranges):
|
||||
if i not in indices_to_delete:
|
||||
for hr in self.highlighted_ranges:
|
||||
if hr.item.description.id.item_id not in ids_to_delete:
|
||||
kept_ranges.append(hr)
|
||||
self.highlighted_ranges = kept_ranges
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,9 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
const searchClient = new MeiliSearch({ host: "http://127.0.0.1:7700" });
|
||||
const client = useContext(GUIClientContext);
|
||||
const dispatch = useDispatch();
|
||||
const workspacePaths = useSelector((state: RootStore) => state.config.workspacePaths);
|
||||
const workspacePaths = useSelector(
|
||||
(state: RootStore) => state.config.workspacePaths
|
||||
);
|
||||
|
||||
const [history, setHistory] = React.useState<string[]>([]);
|
||||
// The position of the current command you are typing now, so the one that will be appended to history once you press enter
|
||||
|
|
@ -184,10 +186,12 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
setCurrentlyInContextQuery(true);
|
||||
const providerAndQuery = segs[segs.length - 1] || "";
|
||||
// Only return context items from the current workspace - the index is currently shared between all sessions
|
||||
const workspaceFilter =
|
||||
workspacePaths && workspacePaths.length > 0
|
||||
? `workspace_dir IN [ ${workspacePaths.map((path) => `"${path}"`).join(", ")} ]`
|
||||
: undefined;
|
||||
const workspaceFilter =
|
||||
workspacePaths && workspacePaths.length > 0
|
||||
? `workspace_dir IN [ ${workspacePaths
|
||||
.map((path) => `"${path}"`)
|
||||
.join(", ")} ]`
|
||||
: undefined;
|
||||
searchClient
|
||||
.index(SEARCH_INDEX_NAME)
|
||||
.search(providerAndQuery, {
|
||||
|
|
@ -418,21 +422,30 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
// Prevent Downshift's default 'Enter' behavior.
|
||||
(event.nativeEvent as any).preventDownshiftDefault = true;
|
||||
|
||||
if (props.onEnter) {props.onEnter(event);}
|
||||
if (props.onEnter) {
|
||||
props.onEnter(event);
|
||||
}
|
||||
setCurrentlyInContextQuery(false);
|
||||
} else if (event.key === "Tab" && items.length > 0) {
|
||||
downshiftProps.setInputValue(items[0].name);
|
||||
event.preventDefault();
|
||||
} else if (event.key === "Tab") {
|
||||
(event.nativeEvent as any).preventDownshiftDefault = true;
|
||||
} else if (
|
||||
(event.key === "ArrowUp" || event.key === "ArrowDown") &&
|
||||
event.currentTarget.value.split("\n").length > 1
|
||||
) {
|
||||
(event.nativeEvent as any).preventDownshiftDefault = true;
|
||||
} else if (event.key === "ArrowUp") {
|
||||
if (positionInHistory == 0) {return;}
|
||||
else if (
|
||||
// Only go back in history if selectionStart is 0
|
||||
// (i.e. the cursor is at the beginning of the input)
|
||||
if (
|
||||
positionInHistory == 0 ||
|
||||
event.currentTarget.selectionStart !== 0
|
||||
) {
|
||||
console.log(
|
||||
"returning",
|
||||
positionInHistory,
|
||||
event.currentTarget.selectionStart
|
||||
);
|
||||
(event.nativeEvent as any).preventDownshiftDefault = true;
|
||||
return;
|
||||
} else if (
|
||||
positionInHistory == history.length &&
|
||||
(history.length === 0 ||
|
||||
history[history.length - 1] !== event.currentTarget.value)
|
||||
|
|
@ -443,6 +456,15 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
setPositionInHistory((prev) => prev - 1);
|
||||
setCurrentlyInContextQuery(false);
|
||||
} else if (event.key === "ArrowDown") {
|
||||
if (
|
||||
positionInHistory === history.length ||
|
||||
event.currentTarget.selectionStart !==
|
||||
event.currentTarget.value.length
|
||||
) {
|
||||
(event.nativeEvent as any).preventDownshiftDefault = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (positionInHistory < history.length) {
|
||||
downshiftProps.setInputValue(history[positionInHistory + 1]);
|
||||
}
|
||||
|
|
@ -454,6 +476,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
setCurrentlyInContextQuery(false);
|
||||
if (downshiftProps.isOpen && items.length > 0) {
|
||||
downshiftProps.closeMenu();
|
||||
(event.nativeEvent as any).preventDownshiftDefault = true;
|
||||
} else {
|
||||
(event.nativeEvent as any).preventDownshiftDefault = true;
|
||||
// Remove focus from the input
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ const StyledButton = styled(Button)<StyledButtonProps>`
|
|||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: red;
|
||||
border-color: ${vscForeground};
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
}
|
||||
|
|
@ -185,13 +185,13 @@ const PillButton = (props: PillButtonProps) => {
|
|||
<GridDiv
|
||||
style={{
|
||||
gridTemplateColumns:
|
||||
props.item.editable && props.addingHighlightedCode
|
||||
props.item.editable && props.areMultipleItems
|
||||
? "1fr 1fr"
|
||||
: "1fr",
|
||||
backgroundColor: vscBackground,
|
||||
}}
|
||||
>
|
||||
{props.item.editable && props.addingHighlightedCode && (
|
||||
{props.item.editable && props.areMultipleItems && (
|
||||
<ButtonDiv
|
||||
data-tooltip-id={`edit-${props.index}`}
|
||||
backgroundColor={"#8800aa55"}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ async function checkOrKillRunningServer(serverUrl: string): Promise<boolean> {
|
|||
if (serverRunning) {
|
||||
console.log("Killing server from old version of Continue");
|
||||
try {
|
||||
await fkill(":65432");
|
||||
await fkill(":65432", { force: true });
|
||||
} catch (e: any) {
|
||||
if (!e.message.includes("Process doesn't exist")) {
|
||||
console.log("Failed to kill old server:", e);
|
||||
|
|
@ -236,28 +236,45 @@ export async function startContinuePythonServer() {
|
|||
setTimeout(spawnChild, delay);
|
||||
};
|
||||
try {
|
||||
const child = spawn(destination, {
|
||||
// NodeJS bug requires not using detached on Windows, otherwise windowsHide is ineffective
|
||||
// Otherwise, detach is preferable
|
||||
const windowsSettings = {
|
||||
windowsHide: true,
|
||||
});
|
||||
child.stdout.on("data", (data: any) => {
|
||||
// console.log(`stdout: ${data}`);
|
||||
});
|
||||
child.stderr.on("data", (data: any) => {
|
||||
console.log(`stderr: ${data}`);
|
||||
});
|
||||
child.on("error", (err: any) => {
|
||||
if (attempts < maxAttempts) {
|
||||
retry();
|
||||
} else {
|
||||
console.error("Failed to start subprocess.", err);
|
||||
}
|
||||
});
|
||||
child.on("exit", (code: any, signal: any) => {
|
||||
console.log("Subprocess exited with code", code, signal);
|
||||
});
|
||||
child.on("close", (code: any, signal: any) => {
|
||||
console.log("Subprocess closed with code", code, signal);
|
||||
});
|
||||
};
|
||||
const macLinuxSettings = {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
};
|
||||
const settings: any =
|
||||
os.platform() === "win32" ? windowsSettings : macLinuxSettings;
|
||||
|
||||
// Spawn the server
|
||||
const child = spawn(destination, settings);
|
||||
|
||||
// Either unref to avoid zombie process, or listen to events because you can
|
||||
if (os.platform() === "win32") {
|
||||
child.stdout.on("data", (data: any) => {
|
||||
// console.log(`stdout: ${data}`);
|
||||
});
|
||||
child.stderr.on("data", (data: any) => {
|
||||
console.log(`stderr: ${data}`);
|
||||
});
|
||||
child.on("error", (err: any) => {
|
||||
if (attempts < maxAttempts) {
|
||||
retry();
|
||||
} else {
|
||||
console.error("Failed to start subprocess.", err);
|
||||
}
|
||||
});
|
||||
child.on("exit", (code: any, signal: any) => {
|
||||
console.log("Subprocess exited with code", code, signal);
|
||||
});
|
||||
child.on("close", (code: any, signal: any) => {
|
||||
console.log("Subprocess closed with code", code, signal);
|
||||
});
|
||||
} else {
|
||||
child.unref();
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.log("Error starting server:", e);
|
||||
retry();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue