diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e0bbdaa49..d8349c922f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Provide more Unicode information about the selected character in the document inspector. - Improve the trimming of whitespaces in the extracted outline labels. +- Adjust the editor’s initial scroll position. ### Fixes diff --git a/CotEditor/Sources/Document Window/Text View/EditorTextView.swift b/CotEditor/Sources/Document Window/Text View/EditorTextView.swift index bc4a449264..0adf2b64f3 100644 --- a/CotEditor/Sources/Document Window/Text View/EditorTextView.swift +++ b/CotEditor/Sources/Document Window/Text View/EditorTextView.swift @@ -370,11 +370,11 @@ final class EditorTextView: NSTextView, CurrentLineHighlighting, MultiCursorEdit override func setFrameSize(_ newSize: NSSize) { - let didChange = newSize != self.frame.size + let oldSize = self.frame.size super.setFrameSize(newSize) - guard didChange else { return } + guard newSize != oldSize else { return } if !self.inLiveResize { self.overscrollResizingDebouncer.schedule() @@ -382,6 +382,12 @@ final class EditorTextView: NSTextView, CurrentLineHighlighting, MultiCursorEdit self.needsUpdateInsertionIndicators = true self.needsUpdateLineHighlight = true + + // set initial scroll position + // -> Otherwise, it would shift by the top inset (2024-12, macOS 15). + if oldSize.width == 0, newSize.width > 0 { + self.scroll(.zero) + } }