File tree Expand file tree Collapse file tree 4 files changed +9
-46
lines changed
Sources/CodeEditSourceEditor/Controller
Tests/CodeEditSourceEditorTests Expand file tree Collapse file tree 4 files changed +9
-46
lines changed Original file line number Diff line number Diff line change 11//
22// TextViewController+IndentLines.swift
3- //
3+ // CodeEditTextView
44//
55// Created by Ludwig, Tom on 11.09.24.
66//
77
8- import CodeEditTextView
98import AppKit
9+ import CodeEditTextView
1010
1111extension TextViewController {
1212 /// Handles indentation and unindentation
@@ -23,7 +23,7 @@ extension TextViewController {
2323 guard !cursorPositions. isEmpty else { return }
2424
2525 textView. undoManager? . beginUndoGrouping ( )
26- for cursorPosition in self . cursorPositions. reversed ( ) {
26+ for cursorPosition in self . cursorPositions. reversed ( ) {
2727 // get lineindex, i.e line-numbers+1
2828 guard let lineIndexes = getHighlightedLines ( for: cursorPosition. range) else { continue }
2929
Original file line number Diff line number Diff line change @@ -67,6 +67,6 @@ extension TextViewController {
6767 } else {
6868 scrollView. automaticallyAdjustsContentInsets = true
6969 }
70- scrollView. contentInsets. bottom = ( contentInsets? . bottom ?? 0 ) + bottomContentInsets
70+ scrollView. contentInsets. bottom = contentInsets? . bottom ?? 0
7171 }
7272}
Original file line number Diff line number Diff line change @@ -104,7 +104,11 @@ public class TextViewController: NSViewController {
104104 ///
105105 /// Measured in a percentage of the view's total height, meaning a `0.3` value will result in overscroll
106106 /// of 1/3 of the view.
107- public var editorOverscroll : CGFloat
107+ public var editorOverscroll : CGFloat {
108+ didSet {
109+ textView. overscrollAmount = editorOverscroll
110+ }
111+ }
108112
109113 /// Whether the code editor should use the theme background color or be transparent
110114 public var useThemeBackground : Bool
@@ -183,18 +187,6 @@ public class TextViewController: NSViewController {
183187
184188 internal var cancellables = Set < AnyCancellable > ( )
185189
186- /// ScrollView's bottom inset using as editor overscroll
187- package var bottomContentInsets : CGFloat {
188- let height = view. frame. height
189- var inset = editorOverscroll * height
190-
191- if height - inset < font. lineHeight * lineHeightMultiple {
192- inset = height - font. lineHeight * lineHeightMultiple
193- }
194-
195- return max ( inset, . zero)
196- }
197-
198190 /// The trailing inset for the editor. Grows when line wrapping is disabled.
199191 package var textViewTrailingInset : CGFloat {
200192 // See https://github.com/CodeEditApp/CodeEditTextView/issues/66
Original file line number Diff line number Diff line change @@ -63,35 +63,6 @@ final class TextViewControllerTests: XCTestCase {
6363 XCTAssertEqual ( color4, NSColor . textColor)
6464 }
6565
66- // MARK: Overscroll
67-
68- func test_editorOverScroll( ) throws {
69- let scrollView = try XCTUnwrap ( controller. view as? NSScrollView )
70- scrollView. frame = . init( x: . zero,
71- y: . zero,
72- width: 100 ,
73- height: 100 )
74-
75- controller. editorOverscroll = 0
76- controller. contentInsets = nil
77- controller. reloadUI ( )
78-
79- // editorOverscroll: 0
80- XCTAssertEqual ( scrollView. contentView. contentInsets. bottom, 0 )
81-
82- controller. editorOverscroll = 0.5
83- controller. reloadUI ( )
84-
85- // editorOverscroll: 0.5
86- XCTAssertEqual ( scrollView. contentView. contentInsets. bottom, 50.0 )
87-
88- controller. editorOverscroll = 1.0
89- controller. reloadUI ( )
90-
91- // editorOverscroll: 1.0
92- XCTAssertEqual ( scrollView. contentView. contentInsets. bottom, 87.0 )
93- }
94-
9566 // MARK: Insets
9667
9768 func test_editorInsets( ) throws {
You can’t perform that action at this time.
0 commit comments