bugfix: misc multifile edit bugs
This commit is contained in:
parent
d2d02614a3
commit
79e0e46dff
14 changed files with 156 additions and 109 deletions
|
|
@ -56,7 +56,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
|
|||
{ accept: boolean; onlyFirst: boolean; filepath: string },
|
||||
void,
|
||||
];
|
||||
"edit/escape": [undefined, void];
|
||||
"edit/exit": [{ shouldFocusEditor: boolean }, void];
|
||||
};
|
||||
|
||||
export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ const getCommandsMap: (
|
|||
"continue.exitEditMode": async () => {
|
||||
captureCommandTelemetry("exitEditMode");
|
||||
editDecorationManager.clear();
|
||||
await sidebar.webviewProtocol?.request("exitEditMode", undefined);
|
||||
void sidebar.webviewProtocol?.request("exitEditMode", undefined);
|
||||
},
|
||||
// "continue.quickEdit": async (args: QuickEditShowParams) => {
|
||||
// let linesOfCode = undefined;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import { getFullyQualifiedPath } from "../util/util";
|
|||
import { getExtensionUri } from "../util/vscode";
|
||||
import { VsCodeIde } from "../VsCodeIde";
|
||||
import { VsCodeWebviewProtocol } from "../webviewProtocol";
|
||||
import { hideGUI } from "../commands";
|
||||
|
||||
/**
|
||||
* A shared messenger class between Core and Webview
|
||||
|
|
@ -400,8 +401,16 @@ export class VsCodeMessenger {
|
|||
vscode.commands.executeCommand("continue.rejectDiff", filepath);
|
||||
}
|
||||
});
|
||||
this.onWebview("edit/escape", async (msg) => {
|
||||
this.editDecorationManager.clear();
|
||||
this.onWebview("edit/exit", async (msg) => {
|
||||
if (msg.data.shouldFocusEditor) {
|
||||
const activeEditor = vscode.window.activeTextEditor;
|
||||
|
||||
if (activeEditor) {
|
||||
vscode.window.showTextDocument(activeEditor.document);
|
||||
}
|
||||
}
|
||||
|
||||
editDecorationManager.clear();
|
||||
});
|
||||
|
||||
/** PASS THROUGH FROM WEBVIEW TO CORE AND BACK **/
|
||||
|
|
|
|||
|
|
@ -63,7 +63,11 @@ export default function CodeToEditListItem({
|
|||
return (
|
||||
<li
|
||||
className="group flex cursor-pointer flex-col"
|
||||
onClick={() => setShowCodeSnippet((showCodeSnippet) => !showCodeSnippet)}
|
||||
onClick={() => {
|
||||
if (!isInsertion) {
|
||||
setShowCodeSnippet((showCodeSnippet) => !showCodeSnippet);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className={`hover:bg-lightgray hover:text-vsc-foreground flex items-center justify-between rounded px-2 py-0.5 transition-colors hover:bg-opacity-20 ${showCodeSnippet && "text-vsc-foreground bg-lightgray bg-opacity-20"}`}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import PostHogPageView from "./PosthogPageView";
|
|||
import AccountDialog from "./AccountDialog";
|
||||
import { AuthProvider } from "../context/Auth";
|
||||
import useHistory from "../hooks/useHistory";
|
||||
import { completeEdit } from "../redux/thunks";
|
||||
import { exitEditMode } from "../redux/thunks";
|
||||
|
||||
const LayoutTopDiv = styled(CustomScrollbarDiv)`
|
||||
height: 100%;
|
||||
|
|
@ -157,7 +157,8 @@ const Layout = () => {
|
|||
useWebviewListener(
|
||||
"focusEdit",
|
||||
async () => {
|
||||
await saveSession();
|
||||
await saveSession(false);
|
||||
dispatch(newSession());
|
||||
dispatch(focusEdit());
|
||||
dispatch(setMode("edit"));
|
||||
},
|
||||
|
|
@ -167,7 +168,8 @@ const Layout = () => {
|
|||
useWebviewListener(
|
||||
"focusEditWithoutClear",
|
||||
async () => {
|
||||
await saveSession();
|
||||
await saveSession(false);
|
||||
dispatch(newSession());
|
||||
dispatch(focusEdit());
|
||||
dispatch(setMode("edit"));
|
||||
},
|
||||
|
|
@ -186,13 +188,6 @@ const Layout = () => {
|
|||
"setEditStatus",
|
||||
async ({ status, fileAfterEdit }) => {
|
||||
dispatch(setEditStatus({ status, fileAfterEdit }));
|
||||
|
||||
if (status === "done") {
|
||||
loadLastSession().catch((e) =>
|
||||
console.error(`Failed to load last session: ${e}`),
|
||||
);
|
||||
dispatch(completeEdit());
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
|
@ -202,7 +197,7 @@ const Layout = () => {
|
|||
console.error(`Failed to load last session: ${e}`),
|
||||
);
|
||||
|
||||
dispatch(completeEdit());
|
||||
dispatch(exitEditMode());
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
|||
import { ApplyState } from "core";
|
||||
import { getMetaKeyLabel } from "../../util";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { selectIsSingleRangeEdit } from "../../redux/slices/sessionSlice";
|
||||
import { selectIsSingleRangeEditOrInsertion } from "../../redux/slices/sessionSlice";
|
||||
|
||||
export interface AcceptRejectAllButtonsProps {
|
||||
pendingApplyStates: ApplyState[];
|
||||
|
|
@ -16,7 +16,7 @@ export default function AcceptRejectAllButtons({
|
|||
onAcceptOrReject,
|
||||
}: AcceptRejectAllButtonsProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const isSingleRangeEdit = useAppSelector(selectIsSingleRangeEdit);
|
||||
const isSingleRangeEdit = useAppSelector(selectIsSingleRangeEditOrInsertion);
|
||||
|
||||
async function handleAcceptOrReject(status: "acceptDiff" | "rejectDiff") {
|
||||
for (const { filepath, streamId } of pendingApplyStates) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { renderChatMessage } from "core/util/messageContent";
|
|||
import { CopyIconButton } from "../gui/CopyIconButton";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import useHistory from "../../hooks/useHistory";
|
||||
import { completeEdit } from "../../redux/thunks/completeEdit";
|
||||
import { exitEditMode } from "../../redux/thunks/exitEditMode";
|
||||
|
||||
export interface EditActionsProps {
|
||||
index: number;
|
||||
|
|
@ -63,7 +63,7 @@ export default function EditActions({ index, item }: EditActionsProps) {
|
|||
console.error(`Failed to load last session: ${e}`),
|
||||
);
|
||||
|
||||
dispatch(completeEdit());
|
||||
dispatch(exitEditMode());
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -153,12 +153,7 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
|
|||
>
|
||||
<TipTapEditor
|
||||
editorState={props.editorState}
|
||||
onEnter={(...args) => {
|
||||
props.onEnter(...args);
|
||||
if (props.isMainInput) {
|
||||
args[2].commands.clearContent(true);
|
||||
}
|
||||
}}
|
||||
onEnter={props.onEnter}
|
||||
placeholder={placeholder}
|
||||
isMainInput={props.isMainInput ?? false}
|
||||
availableContextProviders={filteredContextProviders}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ import {
|
|||
clearCodeToEdit,
|
||||
selectIsInEditMode,
|
||||
} from "../../redux/slices/sessionSlice";
|
||||
import { completeEdit } from "../../redux/thunks";
|
||||
import { exitEditMode } from "../../redux/thunks";
|
||||
|
||||
const InputBoxDiv = styled.div<{ border?: string }>`
|
||||
resize: none;
|
||||
|
|
@ -347,11 +347,10 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
},
|
||||
}),
|
||||
Placeholder.configure({
|
||||
placeholder:
|
||||
props.placeholder ??
|
||||
(historyLengthRef.current === 0
|
||||
? "Ask anything, '@' to add context"
|
||||
: "Ask a follow-up"),
|
||||
placeholder: getPlaceholderText(
|
||||
props.placeholder,
|
||||
historyLengthRef.current,
|
||||
),
|
||||
}),
|
||||
Paragraph.extend({
|
||||
addKeyboardShortcuts() {
|
||||
|
|
@ -419,14 +418,17 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
}
|
||||
},
|
||||
Escape: () => {
|
||||
if (isInEditModeRef.current) {
|
||||
loadLastSession().catch((e) =>
|
||||
console.error(`Failed to load last session: ${e}`),
|
||||
);
|
||||
dispatch(completeEdit());
|
||||
return true;
|
||||
if (inDropdownRef.current || !isInEditModeRef.current) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
loadLastSession().catch((e) =>
|
||||
console.error(`Failed to load last session: ${e}`),
|
||||
);
|
||||
|
||||
dispatch(exitEditMode());
|
||||
|
||||
return true;
|
||||
},
|
||||
ArrowDown: () => {
|
||||
if (
|
||||
|
|
@ -546,6 +548,38 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
setShouldHideToolbar(value);
|
||||
}, 200);
|
||||
|
||||
function getPlaceholderText(
|
||||
placeholder: TipTapEditorProps["placeholder"],
|
||||
historyLength: number,
|
||||
) {
|
||||
if (placeholder) {
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
return historyLength === 0
|
||||
? "Ask anything, '@' to add context"
|
||||
: "Ask a follow-up";
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const placeholder = getPlaceholderText(
|
||||
props.placeholder,
|
||||
historyLengthRef.current,
|
||||
);
|
||||
|
||||
editor.extensionManager.extensions.filter(
|
||||
(extension) => extension.name === "placeholder",
|
||||
)[0].options["placeholder"] = placeholder;
|
||||
|
||||
editor.view.dispatch(editor.state.tr);
|
||||
}, [editor, props.placeholder, historyLengthRef.current]);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.isMainInput) {
|
||||
editor.commands.clearContent(true);
|
||||
}
|
||||
}, [isInEditMode, props.isMainInput]);
|
||||
|
||||
useEffect(() => {
|
||||
if (editor) {
|
||||
const handleFocus = () => {
|
||||
|
|
|
|||
|
|
@ -256,9 +256,12 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
|
|||
const content = getCodeChildrenContent(codeProps.children);
|
||||
|
||||
if (content && contextItemsRef.current) {
|
||||
const ctxItem = contextItemsRef.current.find((ctxItem) =>
|
||||
ctxItem.uri?.value.includes(content),
|
||||
const ctxItem = contextItemsRef.current.find(
|
||||
(ctxItem) =>
|
||||
ctxItem.uri?.value.includes(content) &&
|
||||
ctxItem.uri.type === "file",
|
||||
);
|
||||
|
||||
if (ctxItem) {
|
||||
const rif = ctxItemToRifWithContents(ctxItem);
|
||||
return <FilenameLink rif={rif} />;
|
||||
|
|
|
|||
|
|
@ -36,13 +36,11 @@ import { useTutorialCard } from "../../hooks/useTutorialCard";
|
|||
import { useWebviewListener } from "../../hooks/useWebviewListener";
|
||||
import { selectCurrentToolCall } from "../../redux/selectors/selectCurrentToolCall";
|
||||
import {
|
||||
clearCodeToEdit,
|
||||
clearLastEmptyResponse,
|
||||
newSession,
|
||||
selectIsInEditMode,
|
||||
selectIsSingleRangeEdit,
|
||||
selectIsSingleRangeEditOrInsertion,
|
||||
setInactive,
|
||||
setMode,
|
||||
} from "../../redux/slices/sessionSlice";
|
||||
import { streamResponseThunk } from "../../redux/thunks/streamResponse";
|
||||
import {
|
||||
|
|
@ -66,13 +64,12 @@ import {
|
|||
import { RootState } from "../../redux/store";
|
||||
import FeedbackDialog from "../../components/dialogs/FeedbackDialog";
|
||||
import getMultifileEditPrompt from "../../util/getMultifileEditPrompt";
|
||||
import { setEditDone, submitEdit } from "../../redux/slices/editModeState";
|
||||
import { submitEdit } from "../../redux/slices/editModeState";
|
||||
import { stripImages } from "core/util/messageContent";
|
||||
import resolveEditorContent from "../../components/mainInput/resolveInput";
|
||||
import CodeToEdit from "../../components/CodeToEditCard/CodeToEditCard";
|
||||
import AcceptRejectAllButtons from "../../components/StepContainer/AcceptRejectAllButtons";
|
||||
import CodeToEditCard from "../../components/CodeToEditCard";
|
||||
import { completeEdit } from "../../redux/thunks/completeEdit";
|
||||
import { exitEditMode } from "../../redux/thunks/exitEditMode";
|
||||
|
||||
const StopButton = styled.div`
|
||||
background-color: ${vscBackground};
|
||||
|
|
@ -161,7 +158,9 @@ export function Chat() {
|
|||
);
|
||||
const hasPendingApplies = pendingApplyStates.length > 0;
|
||||
const isInEditMode = useAppSelector(selectIsInEditMode);
|
||||
const isSingleRangeEdit = useAppSelector(selectIsSingleRangeEdit);
|
||||
const isSingleRangeEditOrInsertion = useAppSelector(
|
||||
selectIsSingleRangeEditOrInsertion,
|
||||
);
|
||||
|
||||
const snapToBottom = useCallback(() => {
|
||||
if (!stepsDivRef.current) return;
|
||||
|
|
@ -182,7 +181,7 @@ export function Chat() {
|
|||
setIsAtBottom(true);
|
||||
}, [stepsDivRef, setIsAtBottom]);
|
||||
|
||||
const returnToLastSessinButtonText = isInEditMode
|
||||
const returnToLastSessionButtonText = isInEditMode
|
||||
? "Back to Chat"
|
||||
: "Last Session";
|
||||
|
||||
|
|
@ -228,8 +227,8 @@ export function Chat() {
|
|||
|
||||
const { widget, highlights } = useFindWidget(stepsDivRef);
|
||||
|
||||
const sendChatInput = useCallback(
|
||||
(editorState: JSONContent, modifiers: InputModifiers) => {
|
||||
const sendInput = useCallback(
|
||||
(editorState: JSONContent, modifiers: InputModifiers, editor: Editor) => {
|
||||
if (defaultModel?.provider === "free-trial") {
|
||||
const u = getLocalStorage("ftc");
|
||||
if (u) {
|
||||
|
|
@ -249,7 +248,18 @@ export function Chat() {
|
|||
}
|
||||
}
|
||||
|
||||
dispatch(streamResponseThunk({ editorState, modifiers }));
|
||||
if (isSingleRangeEditOrInsertion) {
|
||||
handleSingleRangeEditOrInsertion(editorState);
|
||||
return;
|
||||
}
|
||||
|
||||
editor.commands.clearContent(true);
|
||||
|
||||
const promptPreamble = isInEditMode
|
||||
? getMultifileEditPrompt(codeToEdit)
|
||||
: undefined;
|
||||
|
||||
dispatch(streamResponseThunk({ editorState, modifiers, promptPreamble }));
|
||||
|
||||
// Increment localstorage counter for popup
|
||||
const currentCount = getLocalStorage("mainTextEntryCounter");
|
||||
|
|
@ -264,14 +274,16 @@ export function Chat() {
|
|||
setLocalStorage("mainTextEntryCounter", 1);
|
||||
}
|
||||
},
|
||||
[history, defaultModel, streamResponse],
|
||||
[
|
||||
history,
|
||||
defaultModel,
|
||||
streamResponse,
|
||||
isSingleRangeEditOrInsertion,
|
||||
codeToEdit,
|
||||
],
|
||||
);
|
||||
|
||||
async function handleSingleRangeEdit(
|
||||
editorState: JSONContent,
|
||||
modifiers: InputModifiers,
|
||||
editor: Editor,
|
||||
) {
|
||||
async function handleSingleRangeEditOrInsertion(editorState: JSONContent) {
|
||||
const [contextItems, __, userInstructions] = await resolveEditorContent(
|
||||
editorState,
|
||||
{
|
||||
|
|
@ -294,27 +306,6 @@ export function Chat() {
|
|||
});
|
||||
|
||||
dispatch(submitEdit(prompt));
|
||||
editor.commands.selectTextblockEnd();
|
||||
}
|
||||
|
||||
async function sendEditInput(
|
||||
editorState: JSONContent,
|
||||
modifiers: InputModifiers,
|
||||
editor: Editor,
|
||||
) {
|
||||
if (isSingleRangeEdit) {
|
||||
handleSingleRangeEdit(editorState, modifiers, editor);
|
||||
} else {
|
||||
const promptPreamble = getMultifileEditPrompt(codeToEdit);
|
||||
|
||||
dispatch(
|
||||
streamResponseThunk({
|
||||
editorState,
|
||||
modifiers,
|
||||
promptPreamble,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
useWebviewListener(
|
||||
|
|
@ -322,7 +313,7 @@ export function Chat() {
|
|||
async () => {
|
||||
saveSession();
|
||||
mainTextInputRef.current?.focus?.();
|
||||
dispatch(completeEdit());
|
||||
dispatch(exitEditMode());
|
||||
},
|
||||
[saveSession],
|
||||
);
|
||||
|
|
@ -362,13 +353,9 @@ export function Chat() {
|
|||
>
|
||||
{item.message.role === "user" ? (
|
||||
<>
|
||||
{isInEditMode && <CodeToEditCard />}
|
||||
{isInEditMode && index === 0 && <CodeToEditCard />}
|
||||
<ContinueInputBox
|
||||
onEnter={async (editorState, modifiers) => {
|
||||
dispatch(
|
||||
streamResponseThunk({ editorState, modifiers, index }),
|
||||
);
|
||||
}}
|
||||
onEnter={sendInput}
|
||||
isLastUserInput={isLastUserInput(index)}
|
||||
isMainInput={false}
|
||||
editorState={item.editorState}
|
||||
|
|
@ -466,18 +453,14 @@ export function Chat() {
|
|||
|
||||
{toolCallState?.status === "generated" && <ToolCallButtons />}
|
||||
|
||||
{history.length === 0 && isInEditMode && <CodeToEdit />}
|
||||
{isInEditMode && history.length === 0 && <CodeToEditCard />}
|
||||
|
||||
{isInEditMode && history.length > 0 ? null : (
|
||||
<ContinueInputBox
|
||||
isMainInput
|
||||
isEditMode={isInEditMode && history.length === 0}
|
||||
isEditMode={isInEditMode}
|
||||
isLastUserInput={false}
|
||||
onEnter={(editorContent, modifiers, editor) => {
|
||||
isInEditMode
|
||||
? sendEditInput(editorContent, modifiers, editor)
|
||||
: sendChatInput(editorContent, modifiers);
|
||||
}}
|
||||
onEnter={sendInput}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
|
@ -499,13 +482,13 @@ export function Chat() {
|
|||
);
|
||||
|
||||
if (isInEditMode) {
|
||||
dispatch(completeEdit());
|
||||
dispatch(exitEditMode());
|
||||
}
|
||||
}}
|
||||
className="flex items-center gap-2"
|
||||
>
|
||||
<ArrowLeftIcon className="h-3 w-3" />
|
||||
{returnToLastSessinButtonText}
|
||||
{returnToLastSessionButtonText}
|
||||
</NewSessionButton>
|
||||
</div>
|
||||
) : null}
|
||||
|
|
@ -513,7 +496,7 @@ export function Chat() {
|
|||
<ConfigErrorIndicator />
|
||||
</div>
|
||||
|
||||
{hasPendingApplies && isSingleRangeEdit && (
|
||||
{hasPendingApplies && isSingleRangeEditOrInsertion && (
|
||||
<AcceptRejectAllButtons
|
||||
pendingApplyStates={pendingApplyStates}
|
||||
onAcceptOrReject={() => {
|
||||
|
|
@ -521,7 +504,7 @@ export function Chat() {
|
|||
console.error(`Failed to load last session: ${e}`),
|
||||
);
|
||||
|
||||
dispatch(completeEdit());
|
||||
dispatch(exitEditMode());
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,22 @@ type SessionState = {
|
|||
};
|
||||
|
||||
function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) {
|
||||
return a.filepath === b.filepath && a.contents === b.contents;
|
||||
if (a.filepath !== b.filepath || a.contents !== b.contents) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("range" in a && "range" in b) {
|
||||
const rangeA = a.range;
|
||||
const rangeB = b.range;
|
||||
|
||||
return (
|
||||
rangeA.start.line === rangeB.start.line &&
|
||||
rangeA.end.line === rangeB.end.line
|
||||
);
|
||||
}
|
||||
|
||||
// If neither has a range, they are considered equal in this context
|
||||
return !("range" in a) && !("range" in b);
|
||||
}
|
||||
|
||||
function getBaseHistoryItem(): ChatHistoryItemWithMessageId {
|
||||
|
|
@ -500,12 +515,16 @@ export const sessionSlice = createSlice({
|
|||
selectIsInEditMode: (state) => {
|
||||
return state.mode === "edit";
|
||||
},
|
||||
selectIsSingleRangeEdit: (state) => {
|
||||
return (
|
||||
state.mode === "edit" &&
|
||||
(state.codeToEdit.length === 0 ||
|
||||
(state.codeToEdit.length === 1 && "range" in state.codeToEdit[0]))
|
||||
);
|
||||
selectIsSingleRangeEditOrInsertion: (state) => {
|
||||
if (state.mode !== "edit") {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isInsertion = state.codeToEdit.length === 0;
|
||||
const selectIsSingleRangeEdit =
|
||||
state.codeToEdit.length === 1 && "range" in state.codeToEdit[0];
|
||||
|
||||
return selectIsSingleRangeEdit || isInsertion;
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
|
|
@ -579,7 +598,7 @@ export const {
|
|||
export const {
|
||||
selectIsGatheringContext,
|
||||
selectIsInEditMode,
|
||||
selectIsSingleRangeEdit,
|
||||
selectIsSingleRangeEditOrInsertion,
|
||||
} = sessionSlice.selectors;
|
||||
|
||||
export default sessionSlice.reducer;
|
||||
|
|
|
|||
|
|
@ -2,16 +2,19 @@ import { createAsyncThunk } from "@reduxjs/toolkit";
|
|||
import {
|
||||
clearCodeToEdit,
|
||||
selectIsInEditMode,
|
||||
selectIsSingleRangeEditOrInsertion,
|
||||
setMode,
|
||||
} from "../slices/sessionSlice";
|
||||
import { ThunkApiType } from "../store";
|
||||
import { setEditDone } from "../slices/editModeState";
|
||||
|
||||
export const completeEdit = createAsyncThunk<void, undefined, ThunkApiType>(
|
||||
export const exitEditMode = createAsyncThunk<void, undefined, ThunkApiType>(
|
||||
"edit/complete",
|
||||
async (_, { dispatch, extra, getState }) => {
|
||||
const state = getState();
|
||||
const isInEditMode = selectIsInEditMode(state);
|
||||
const isSingleRangeEditOrInsertion =
|
||||
selectIsSingleRangeEditOrInsertion(state);
|
||||
|
||||
if (!isInEditMode) {
|
||||
return;
|
||||
|
|
@ -19,8 +22,10 @@ export const completeEdit = createAsyncThunk<void, undefined, ThunkApiType>(
|
|||
|
||||
dispatch(setMode("chat"));
|
||||
dispatch(clearCodeToEdit());
|
||||
setEditDone();
|
||||
dispatch(setEditDone());
|
||||
|
||||
extra.ideMessenger.post("edit/escape", undefined);
|
||||
extra.ideMessenger.post("edit/exit", {
|
||||
shouldFocusEditor: isSingleRangeEditOrInsertion,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
export { completeEdit } from "./completeEdit";
|
||||
export { exitEditMode } from "./exitEditMode";
|
||||
export { gatherContext } from "./gatherContext";
|
||||
export { handleErrors } from "./handleErrors";
|
||||
export { resetStateForNewMessage } from "./resetStateForNewMessage";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue