Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/app/src/pages/session/file-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,15 @@ export function FileTabContent(props: { tab: string }) {
cacheKey: cacheKey(),
}}
enableLineSelection
enableHoverUtility
enableGutterUtility
selectedLines={activeSelection()}
commentedLines={commentedLines()}
onRendered={() => {
scrollSync.queueRestore()
}}
annotations={commentsUi.annotations()}
renderAnnotation={commentsUi.renderAnnotation}
renderHoverUtility={commentsUi.renderHoverUtility}
renderGutterUtility={commentsUi.renderHoverUtility}
onLineSelected={(range: SelectedLineRange | null) => {
commentsUi.onLineSelected(range)
}}
Expand Down
10 changes: 4 additions & 6 deletions packages/ui/src/components/file.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type SharedProps<T> = {
classList?: ComponentProps<"div">["classList"]
media?: FileMediaOptions
search?: FileSearchControl
enableGutterUtility?: boolean
renderGutterUtility?: (getHoveredRow: () => any) => HTMLElement | null | undefined
}

export type FileSearchHandle = {
Expand Down Expand Up @@ -211,13 +213,9 @@ function useFileViewer(config: ViewerConfig) {
if (event.button !== 0) return

const hit = config.lineFromMouseEvent(event)
if (hit.numberColumn) {
bridge.begin(true, hit.line)
return
}
if (hit.line === undefined) return

bridge.begin(false, hit.line)
bridge.begin(hit.numberColumn, hit.line)
dragStart = hit.line
dragEnd = hit.line
dragMoved = false
Expand Down Expand Up @@ -249,7 +247,7 @@ function useFileViewer(config: ViewerConfig) {

const handleMouseUp = () => {
if (!config.enableLineSelection()) return
if (bridge.finish() === "numbers") return
bridge.finish()
if (dragStart === undefined) return

if (!dragMoved) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/session-review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -620,13 +620,13 @@ export const SessionReview = (props: SessionReviewProps) => {
props.onDiffRendered?.()
}}
enableLineSelection={props.onLineComment != null}
enableHoverUtility={props.onLineComment != null}
enableGutterUtility={props.onLineComment != null}
onLineSelected={handleLineSelected}
onLineSelectionEnd={handleLineSelectionEnd}
onLineNumberSelectionEnd={commentsUi.onLineNumberSelectionEnd}
annotations={commentsUi.annotations()}
renderAnnotation={commentsUi.renderAnnotation}
renderHoverUtility={props.onLineComment ? commentsUi.renderHoverUtility : undefined}
renderGutterUtility={props.onLineComment ? commentsUi.renderHoverUtility : undefined}
selectedLines={selectedLines()}
commentedLines={commentedLines()}
media={{
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/pierre/selection-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ export function createLineNumberSelectionBridge() {
},
finish() {
const current = mode
pending = current === "numbers" && moved
pending = current === "numbers"
clear()
return current
},
consume(range: SelectedLineRange | null) {
const result = pending && !isSingleLineSelection(range)
consume(_range: SelectedLineRange | null) {
const result = pending
pending = false
return result
},
Expand Down
Loading