Skip to content

Commit 0a4da13

Browse files
Set default ruler width (#205)
<!--- IMPORTANT: If this PR addresses multiple unrelated issues, it will be closed until separated. --> ### Description Adds a minimum ruler width equal to 4 digits wide to reduce layout shift while scrolling. ### Related Issues <!--- REQUIRED: Tag all related issues (e.g. * #123) --> <!--- If this PR resolves the issue please specify (e.g. * closes #123) --> <!--- If this PR addresses multiple issues, these issues must be related to one other --> * N/A, discussed a couple times in discord. ### Checklist <!--- Add things that are not yet implemented above --> - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code ### Screenshots Previous: <img width="356" alt="Screenshot 2023-07-11 at 12 28 26 PM" src="https://github.com/CodeEditApp/CodeEditTextView/assets/35942988/469044fa-189f-41d8-83ca-367f2244fe82"> Now: <img width="321" alt="Screenshot 2023-07-11 at 12 27 51 PM" src="https://github.com/CodeEditApp/CodeEditTextView/assets/35942988/547dcdda-f50e-4be6-a065-7fef5b6e7cd7">
1 parent 8fba782 commit 0a4da13

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Package.resolved

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/CodeEditTextView/Controller/STTextViewController.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,15 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
207207
: NSColor.selectedTextBackgroundColor.withSystemEffect(.disabled)
208208
rulerView.baselineOffset = baselineOffset
209209
rulerView.highlightSelectedLine = isEditable
210-
rulerView.rulerInsets = STRulerInsets(leading: rulerFont.pointSize * 1.6, trailing: 8)
210+
rulerView.rulerInsets = STRulerInsets(leading: 12, trailing: 8)
211211
rulerView.font = rulerFont
212212
rulerView.backgroundColor = theme.background
213+
rulerView.ruleThickness = max(
214+
NSString(string: "1000").size(withAttributes: [.font: rulerFont]).width
215+
+ rulerView.rulerInsets.leading
216+
+ rulerView.rulerInsets.trailing,
217+
rulerView.ruleThickness
218+
)
213219
if self.isEditable == false {
214220
rulerView.selectedLineTextColor = nil
215221
rulerView.selectedLineHighlightColor = .clear

0 commit comments

Comments
 (0)