mirror of
https://github.com/run-llama/ai-chatbot.git
synced 2026-07-01 21:14:02 -04:00
fix: preserve cursor position on code editor saves (#683)
This commit is contained in:
@@ -428,9 +428,7 @@ function PureBlock({
|
||||
<BlockCloseButton />
|
||||
|
||||
<div className="flex flex-col">
|
||||
<div className="font-medium">
|
||||
{document?.title ?? block.title}
|
||||
</div>
|
||||
<div className="font-medium">{block.title}</div>
|
||||
|
||||
{isContentDirty ? (
|
||||
<div className="text-sm text-muted-foreground">
|
||||
|
||||
@@ -59,9 +59,12 @@ function PureCodeEditor({ content, saveContent, status }: EditorProps) {
|
||||
}
|
||||
});
|
||||
|
||||
const currentSelection = editorRef.current.state.selection;
|
||||
|
||||
const newState = EditorState.create({
|
||||
doc: editorRef.current.state.doc,
|
||||
extensions: [basicSetup, python(), oneDark, updateListener],
|
||||
selection: currentSelection,
|
||||
});
|
||||
|
||||
editorRef.current.setState(newState);
|
||||
|
||||
@@ -145,6 +145,7 @@ const PureHitboxLayer = ({
|
||||
? { ...block, isVisible: true }
|
||||
: {
|
||||
...block,
|
||||
title: result.title,
|
||||
documentId: result.id,
|
||||
kind: result.kind,
|
||||
isVisible: true,
|
||||
|
||||
Reference in New Issue
Block a user