Skip to content

Commit 94e2183

Browse files
Fix resizing animaition, use line height from pref
1 parent 255c88e commit 94e2183

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

CodeEdit/Features/NavigatorArea/FindNavigator/FindNavigatorResultList/FindNavigatorListViewController.swift

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,25 +210,37 @@ extension FindNavigatorListViewController: NSOutlineViewDelegate {
210210

211211
func outlineView(_ outlineView: NSOutlineView, heightOfRowByItem item: Any) -> CGFloat {
212212
if let item = item as? SearchResultMatchModel {
213+
let columnWidth = outlineView.tableColumns.first?.width ?? outlineView.frame.width
214+
let indentationLevel = outlineView.level(forItem: item)
215+
let indentationSpace = CGFloat(indentationLevel) * outlineView.indentationPerLevel
216+
let availableWidth = columnWidth - indentationSpace - 24
217+
218+
// Create a temporary text field for measurement
213219
let tempView = NSTextField(wrappingLabelWithString: item.attributedLabel().string)
214220
tempView.allowsDefaultTighteningForTruncation = false
215221
tempView.cell?.truncatesLastVisibleLine = true
216222
tempView.cell?.wraps = true
217-
tempView.maximumNumberOfLines = 3
218-
tempView.attributedStringValue = item.attributedLabel()
219-
tempView.layout()
220-
let width = outlineView.frame.width - outlineView.indentationPerLevel*2 - 24
221-
return tempView.sizeThatFits(
222-
NSSize(width: width, height: CGFloat.greatestFiniteMagnitude)
223-
).height + 8
224-
} else {
225-
return rowHeight
223+
tempView.maximumNumberOfLines = Settings.shared.preferences.general.findNavigatorDetail.rawValue
224+
tempView.preferredMaxLayoutWidth = availableWidth
225+
226+
let height = tempView.sizeThatFits(
227+
NSSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude)
228+
).height
229+
return max(height + 8, rowHeight)
226230
}
231+
return rowHeight
227232
}
228233

229234
func outlineViewColumnDidResize(_ notification: Notification) {
235+
// Disable animations temporarily
236+
NSAnimationContext.beginGrouping()
237+
NSAnimationContext.current.duration = 0
238+
230239
let indexes = IndexSet(integersIn: 0..<searchItems.count)
231240
outlineView.noteHeightOfRows(withIndexesChanged: indexes)
241+
242+
NSAnimationContext.endGrouping()
243+
outlineView.layoutSubtreeIfNeeded()
232244
}
233245
}
234246

0 commit comments

Comments
 (0)