diff options
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 |
