@@ -209,26 +209,69 @@ extension FindNavigatorListViewController: NSOutlineViewDelegate {
209
209
}
210
210
211
211
func outlineView( _ outlineView: NSOutlineView , heightOfRowByItem item: Any ) -> CGFloat {
212
- if let item = item as? SearchResultMatchModel {
213
- let tempView = NSTextField ( wrappingLabelWithString: item. attributedLabel ( ) . string)
214
- tempView. allowsDefaultTighteningForTruncation = false
215
- tempView. cell? . truncatesLastVisibleLine = true
212
+ if let matchItem = item as? SearchResultMatchModel {
213
+ guard let column = outlineView. tableColumns. first else {
214
+ return rowHeight
215
+ }
216
+ let columnWidth = column. width
217
+ let indentationLevel = outlineView. level ( forItem: item)
218
+ let indentationSpace = CGFloat ( indentationLevel) * outlineView. indentationPerLevel
219
+ let horizontalPaddingAndFixedElements : CGFloat = 24.0
220
+
221
+ let availableWidth = columnWidth - indentationSpace - horizontalPaddingAndFixedElements
222
+
223
+ guard availableWidth > 0 else {
224
+ // Not enough space to display anything, return minimum height
225
+ return max ( rowHeight, Settings . shared. preferences. general. projectNavigatorSize. rowHeight)
226
+ }
227
+
228
+ let attributedString = matchItem. attributedLabel ( )
229
+
230
+ let tempView = NSTextField ( )
231
+ tempView. allowsEditingTextAttributes = true
232
+ tempView. attributedStringValue = attributedString
233
+
234
+ tempView. isEditable = false
235
+ tempView. isBordered = false
236
+ tempView. drawsBackground = false
237
+ tempView. alignment = . natural
238
+
216
239
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
240
+ tempView. cell? . usesSingleLineMode = false
241
+ tempView. lineBreakMode = . byWordWrapping
242
+ tempView. maximumNumberOfLines = Settings . shared. preferences. general. findNavigatorDetail. rawValue
243
+ tempView. preferredMaxLayoutWidth = availableWidth
244
+
245
+ var calculatedHeight = tempView. sizeThatFits (
246
+ NSSize ( width: availableWidth, height: . greatestFiniteMagnitude)
247
+ ) . height
248
+
249
+ // Total vertical padding (top + bottom) within the cell around the text
250
+ let verticalPaddingInCell : CGFloat = 8.0
251
+ calculatedHeight += verticalPaddingInCell
252
+ return max ( calculatedHeight, self . rowHeight)
226
253
}
254
+ // For parent items
255
+ return prefs. general. projectNavigatorSize. rowHeight
227
256
}
228
257
229
258
func outlineViewColumnDidResize( _ notification: Notification ) {
230
- let indexes = IndexSet ( integersIn: 0 ..< searchItems. count)
231
- outlineView. noteHeightOfRows ( withIndexesChanged: indexes)
259
+ // Disable animations temporarily
260
+ NSAnimationContext . beginGrouping ( )
261
+ NSAnimationContext . current. duration = 0
262
+
263
+ var rowsToUpdate = IndexSet ( )
264
+ for row in 0 ..< outlineView. numberOfRows {
265
+ if let item = outlineView. item ( atRow: row) , item is SearchResultMatchModel {
266
+ rowsToUpdate. insert ( row)
267
+ }
268
+ }
269
+ if !rowsToUpdate. isEmpty {
270
+ outlineView. noteHeightOfRows ( withIndexesChanged: rowsToUpdate)
271
+ }
272
+
273
+ NSAnimationContext . endGrouping ( )
274
+ outlineView. layoutSubtreeIfNeeded ( )
232
275
}
233
276
}
234
277
0 commit comments