1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-29 03:53:38 +03:00

GH-521 Compute the max width differently

This commit is contained in:
Tae Won Ha 2017-10-16 21:29:47 +02:00
parent d579db9de5
commit 5cce06d889
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 11 additions and 20 deletions

View File

@ -132,8 +132,6 @@ extension AppDelegate {
}
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplicationTerminateReply {
return .terminateNow
self.stateContext.savePrefs()
if self.hasDirtyWindows && self.hasMainWindows {

View File

@ -94,9 +94,8 @@ class FileOutlineView: NSOutlineView,
}
override func reloadData() {
stdoutLog.debug("---------------------- start")
self.widths.removeAll()
super.reloadData()
stdoutLog.debug("---------------------- finish")
}
func select(_ url: URL) {
@ -135,6 +134,8 @@ class FileOutlineView: NSOutlineView,
fileprivate var root: FileBrowserItem
fileprivate var widths = [String: CGFloat]()
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@ -178,14 +179,14 @@ class FileOutlineView: NSOutlineView,
.filter { (_, fileBrowserItem) in newPreparedChildren.contains(fileBrowserItem) == false }
.map { (idx, _) in idx }
indicesToRemove.forEach { self.widths.removeValue(forKey: curPreparedChildren[$0].url.path) }
fileLog.debug("\(fileBrowserItem): \(curPreparedChildren) vs. \(indicesToRemove)")
fileBrowserItem.children = curChildren.filter { newChildren.contains($0) }
let parent = fileBrowserItem == self.root ? nil : fileBrowserItem
self.removeItems(at: IndexSet(indicesToRemove), inParent: parent)
stdoutLog.mark()
}
fileprivate func handleAdditions(for fileBrowserItem: FileBrowserItem,
@ -208,8 +209,6 @@ class FileOutlineView: NSOutlineView,
let parent = fileBrowserItem == self.root ? nil : fileBrowserItem
self.insertItems(at: IndexSet(indicesToInsert), inParent: parent)
stdoutLog.mark()
}
fileprivate func sortedChildren(of url: URL) -> [FileBrowserItem] {
@ -333,12 +332,8 @@ extension FileOutlineView {
return
}
let width = (0 ..< self.numberOfRows).map {
self.cellWidth(for: self.view(atColumn: 0, row: $0, makeIfNecessary: true), level: self.level(forRow: $0))
}.max() ?? CGFloat(100)
column.minWidth = width
column.maxWidth = width
column.minWidth = self.widths.values.max() ?? 100
column.maxWidth = self.widths.values.max() ?? 100
}
}
@ -368,15 +363,15 @@ extension FileOutlineView {
let icon = FileUtils.icon(forUrl: fileBrowserItem.url)
cell.image = fileBrowserItem.isHidden ? icon?.tinting(with: NSColor.white.withAlphaComponent(0.4)) : icon
self.widths[fileBrowserItem.url.path] = self.cellWidth(for: cell, level: self.level(forItem: item))
self.adjustColumnWidths()
return cell
}
func outlineView(_: NSOutlineView, heightOfRowByItem item: Any) -> CGFloat {
return 20
}
func outlineViewItemDidCollapse(_ notification: Notification) {
}
}
// MARK: - Actions

View File

@ -116,9 +116,7 @@ class MainWindow: NSObject,
self.neoVimView = NeoVimView(frame: .zero, config: neoVimViewConfig)
self.neoVimView.configureForAutoLayout()
let dummy = NSView(frame: .zero)
dummy.configureForAutoLayout()
self.workspace = Workspace(mainView: dummy)
self.workspace = Workspace(mainView: self.neoVimView)
var tools: [Tools: WorkspaceTool] = [:]
if state.activeTools[.preview] == true {