diff options
| author | adamelmore <[email protected]> | 2026-01-24 12:19:39 -0600 |
|---|---|---|
| committer | adamelmore <[email protected]> | 2026-01-24 12:41:50 -0600 |
| commit | 42b802b688f92e7077c5a828df4c62296c326bbf (patch) | |
| tree | 00f4b6f5d48680e7dc9123f9ec92a999b7196260 /packages/ui/src/components/code.tsx | |
| parent | fa1a54ba3d44a584cfeea23de0364cbbaba449f1 (diff) | |
| download | opencode-42b802b688f92e7077c5a828df4c62296c326bbf.tar.gz opencode-42b802b688f92e7077c5a828df4c62296c326bbf.zip | |
fix(app): line selection ux fixes
Diffstat (limited to 'packages/ui/src/components/code.tsx')
| -rw-r--r-- | packages/ui/src/components/code.tsx | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/packages/ui/src/components/code.tsx b/packages/ui/src/components/code.tsx index 16a915d9d..eb0ba7826 100644 --- a/packages/ui/src/components/code.tsx +++ b/packages/ui/src/components/code.tsx @@ -66,28 +66,16 @@ export function Code<T>(props: CodeProps<T>) { "selectedLines", "commentedLines", "onRendered", - "onLineSelectionEnd", ]) const [rendered, setRendered] = createSignal(0) - const handleLineClick: FileOptions<T>["onLineClick"] = (info) => { - props.onLineClick?.(info) - - if (props.enableLineSelection !== true) return - if (info.numberColumn) return - if (!local.selectedLines) return - - file().setSelectedLines(null) - } - const file = createMemo( () => new File<T>( { ...createDefaultOptions<T>("unified"), ...others, - onLineClick: props.enableLineSelection === true || props.onLineClick ? handleLineClick : undefined, }, getWorkerPool("unified"), ), @@ -332,12 +320,21 @@ export function Code<T>(props: CodeProps<T>) { if (props.enableLineSelection !== true) return if (dragStart === undefined) return - if (dragMoved) { - pendingSelectionEnd = true - scheduleDragUpdate() - scheduleSelectionUpdate() + if (!dragMoved) { + pendingSelectionEnd = false + const line = dragStart + setSelectedLines({ start: line, end: line }) + props.onLineSelectionEnd?.(lastSelection) + dragStart = undefined + dragEnd = undefined + dragMoved = false + return } + pendingSelectionEnd = true + scheduleDragUpdate() + scheduleSelectionUpdate() + dragStart = undefined dragEnd = undefined dragMoved = false |
