detectAndWrapLongColumns automatically enables wrapping for columns with long content Analyzes first N rows to detect if columns have text longer than threshold
(b *Buffer, sampleSize int, threshold int)
| 241 | // detectAndWrapLongColumns automatically enables wrapping for columns with long content |
| 242 | // Analyzes first N rows to detect if columns have text longer than threshold |
| 243 | func detectAndWrapLongColumns(b *Buffer, sampleSize int, threshold int) { |
| 244 | b.mu.RLock() |
| 245 | defer b.mu.RUnlock() |
| 246 | |
| 247 | // Determine how many rows to sample |
| 248 | maxSample := sampleSize |
| 249 | if b.rowLen < maxSample { |
| 250 | maxSample = b.rowLen |
| 251 | } |
| 252 | |
| 253 | // Skip header row in analysis if it exists |
| 254 | startRow := 0 |
| 255 | if b.rowFreeze > 0 { |
| 256 | startRow = b.rowFreeze |
| 257 | } |
| 258 | |
| 259 | // Track maximum length found in each column |
| 260 | maxLengths := make([]int, b.colLen) |
| 261 | |
| 262 | // Sample rows to find maximum content length per column |
| 263 | for r := startRow; r < maxSample; r++ { |
| 264 | for c := 0; c < b.colLen; c++ { |
| 265 | if c < len(b.cont[r]) { |
| 266 | cellLen := len(b.cont[r][c]) |
| 267 | if cellLen > maxLengths[c] { |
| 268 | maxLengths[c] = cellLen |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | // Enable wrapping for columns that exceed threshold |
| 275 | for c := 0; c < b.colLen; c++ { |
| 276 | if maxLengths[c] > threshold { |
| 277 | // Only set if not already manually configured |
| 278 | if _, exists := wrappedColumns[c]; !exists { |
| 279 | wrappedColumns[c] = getColumnMaxWidth(c) |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | // performSearch searches for a query string in the buffer and stores results |
| 286 | // Supports both plain text and regex search modes with parallel column scanning |
no test coverage detected