mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Restore tab selection (fix #860)
This commit is contained in:
parent
9426d376d0
commit
f7d7f26dc6
@ -16,6 +16,7 @@ Change Log
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix an issue where selected inspector pane was not stored.
|
||||
- Fix an issue where the writing direction (RtL) was not delivered to printing.
|
||||
- Fix layout in some localized environment.
|
||||
|
||||
|
@ -164,6 +164,7 @@ extension DefaultKeys {
|
||||
static let showStatusBar = DefaultKey<Bool>("showStatusArea")
|
||||
|
||||
// hidden settings
|
||||
static let selectedInspectorPaneIndex = DefaultKey<Int>("selectedInspectorPaneIndex")
|
||||
static let headerFooterDateFormat = DefaultKey<String>("headerFooterDateFormat")
|
||||
static let headerFooterPathAbbreviatingWithTilde = DefaultKey<Bool>("headerFooterPathAbbreviatingWithTilde")
|
||||
static let autoCompletionDelay = DefaultKey<Double>("autoCompletionDelay")
|
||||
|
@ -173,6 +173,7 @@ struct DefaultSettings {
|
||||
.showStatusBar: true,
|
||||
|
||||
// ------ hidden settings ------
|
||||
.selectedInspectorPaneIndex: 0,
|
||||
.headerFooterDateFormat: "YYYY-MM-dd HH:mm",
|
||||
.headerFooterPathAbbreviatingWithTilde: true,
|
||||
.autoCompletionDelay: 0.25,
|
||||
|
@ -68,6 +68,9 @@ final class SidebarViewController: NSTabViewController {
|
||||
segmentedControl.bind(.selectedIndex, to: self, withKeyPath: #keyPath(selectedTabViewItemIndex))
|
||||
}
|
||||
|
||||
// select last used pane
|
||||
self.selectedTabViewItemIndex = UserDefaults.standard[.selectedInspectorPaneIndex]
|
||||
|
||||
// set accessibility
|
||||
self.view.setAccessibilityElement(true)
|
||||
self.view.setAccessibilityRole(.group)
|
||||
@ -101,7 +104,17 @@ final class SidebarViewController: NSTabViewController {
|
||||
guard selectedTabViewItemIndex != oldValue else { return }
|
||||
|
||||
self.delegate?.tabViewController(self, didSelect: self.selectedTabViewItemIndex)
|
||||
|
||||
if self.isViewLoaded { // avoid storing initial state (set in the storyboard)
|
||||
UserDefaults.standard[.selectedInspectorPaneIndex] = self.selectedTabViewItemIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override func tabView(_ tabView: NSTabView, didSelect tabViewItem: NSTabViewItem?) {
|
||||
|
||||
super.tabView(tabView, didSelect: tabViewItem)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user