set cursor on geo click

This commit is contained in:
Kurt Hutten IrevDev
2023-01-06 09:07:22 +11:00
parent f9e2f163a4
commit 248317f354
3 changed files with 28 additions and 9 deletions

View File

@ -46,6 +46,7 @@ interface StoreState {
setEditorView: (editorView: EditorView) => void
highlightRange: [number, number]
setHighlightRange: (range: Range) => void
setCursor: (cursor: number) => void
selectionRange: [number, number]
setSelectionRange: (range: Range) => void
guiMode: GuiModes
@ -83,6 +84,13 @@ export const useStore = create<StoreState>()((set, get) => ({
editorView.dispatch({ effects: addLineHighlight.of(highlightRange) })
}
},
setCursor: (cursor: number) => {
const editorView = get().editorView
if (!editorView) return
editorView.dispatch({
selection: { anchor: cursor, head: cursor },
})
},
selectionRange: [0, 0],
setSelectionRange: (selectionRange) => {
set({ selectionRange })