From c0fee752eacfa8b7ea2d37955dd72fb117b2e197 Mon Sep 17 00:00:00 2001 From: David Albert Date: Mon, 18 Mar 2024 13:54:35 -0400 Subject: [PATCH 1/2] Autoscroll even if you hold Shift while clicking --- Watt/TextView/TextView+Mouse.swift | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Watt/TextView/TextView+Mouse.swift b/Watt/TextView/TextView+Mouse.swift index 6184fb89..ead81ca6 100644 --- a/Watt/TextView/TextView+Mouse.swift +++ b/Watt/TextView/TextView+Mouse.swift @@ -21,18 +21,12 @@ extension TextView { if event.modifierFlags.intersection(.deviceIndependentFlagsMask) == .shift { selection = SelectionNavigator(selection).selection(extendingTo: point, dataSource: layoutManager) - return - } - - switch event.clickCount { - case 1: + } else if event.clickCount == 1 { selection = SelectionNavigator.selection(interactingAt: point, dataSource: layoutManager) - case 2: + } else if event.clickCount == 2 { selection = SelectionNavigator(selection).selection(for: .word, enclosing: point, dataSource: layoutManager) - case 3: + } else if event.clickCount == 3 { selection = SelectionNavigator(selection).selection(for: .paragraph, enclosing: point, dataSource: layoutManager) - default: - break } var mouseEvent = event From 628b3399b2c77800f9427a87191fbc86a9799173 Mon Sep 17 00:00:00 2001 From: David Albert Date: Mon, 18 Mar 2024 14:09:57 -0400 Subject: [PATCH 2/2] Fix crash when dragging to the top with paragraph granularity --- Watt/LayoutManager/Buffer.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Watt/LayoutManager/Buffer.swift b/Watt/LayoutManager/Buffer.swift index 64e4a682..dd981400 100644 --- a/Watt/LayoutManager/Buffer.swift +++ b/Watt/LayoutManager/Buffer.swift @@ -321,7 +321,12 @@ extension Buffer: HighlighterDelegate { extension Buffer: TextContent { func index(ofParagraphBoundaryBefore i: Buffer.Index) -> Buffer.Index { - lines.index(before: i) + var j = i + if lines.isBoundary(j) { + j = index(before: j) + } + + return lines.index(roundingDown: j) } func index(ofParagraphBoundaryAfter i: Buffer.Index) -> Buffer.Index {