summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/components/code.tsx
diff options
context:
space:
mode:
authoradamelmore <[email protected]>2026-01-24 12:19:39 -0600
committeradamelmore <[email protected]>2026-01-24 12:41:50 -0600
commit42b802b688f92e7077c5a828df4c62296c326bbf (patch)
tree00f4b6f5d48680e7dc9123f9ec92a999b7196260 /packages/ui/src/components/code.tsx
parentfa1a54ba3d44a584cfeea23de0364cbbaba449f1 (diff)
downloadopencode-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.tsx29
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