Skip to content

Commit

Permalink
Fix line numbers not displayed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
octree committed Apr 6, 2022
1 parent 11ffd00 commit abcc746
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CodeEditModules/Modules/CodeFile/src/CodeEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ struct CodeEditor: NSViewRepresentable {
}

func updateNSView(_ scrollView: NSScrollView, context: Context) {
if let textView = scrollView.documentView as? CodeEditorTextView {
updateTextView(textView)
guard let textView = scrollView.documentView as? CodeEditorTextView else {
return
}
if let rulerView = scrollView.verticalRulerView as? LineGutter,
content.wrappedValue != textView.string {
rulerView.invalidateLineIndices()
}
updateTextView(textView)
}

final class Coordinator: NSObject, NSTextViewDelegate {
Expand Down

0 comments on commit abcc746

Please sign in to comment.