restores Helder in all its glory
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import Foundation
|
||||
|
||||
/// One matching line.
|
||||
public struct ContentHit: Sendable, Equatable {
|
||||
/// 1-based line number.
|
||||
public var line: Int
|
||||
/// The line text, capped at `SearchLimits.maxLineLength` characters.
|
||||
public var text: String
|
||||
/// UTF-16 offset of the first match in `text`, clamped to its length.
|
||||
public var matchOffset: Int
|
||||
|
||||
public init(line: Int, text: String, matchOffset: Int) {
|
||||
self.line = line
|
||||
self.text = text
|
||||
self.matchOffset = matchOffset
|
||||
}
|
||||
}
|
||||
|
||||
/// All hits in one file, in the order ripgrep reported them.
|
||||
public struct ContentGroup: Sendable, Equatable, Identifiable {
|
||||
public var path: String
|
||||
public var hits: [ContentHit]
|
||||
public var id: String { path }
|
||||
|
||||
public init(path: String, hits: [ContentHit]) {
|
||||
self.path = path
|
||||
self.hits = hits
|
||||
}
|
||||
}
|
||||
|
||||
/// A file-name match in the search overlay's right column.
|
||||
public struct FileNameMatch: Sendable, Equatable {
|
||||
public var path: String
|
||||
/// Matched character offsets in the basename; nil when only the full path matched.
|
||||
public var nameIndices: [Int]?
|
||||
/// 0 = basename match, 1 = path-only match; lower sorts first.
|
||||
public var rank: Int
|
||||
/// Offset of the first matched character; lower sorts first.
|
||||
public var position: Int
|
||||
|
||||
public init(path: String, nameIndices: [Int]?, rank: Int, position: Int) {
|
||||
self.path = path
|
||||
self.nameIndices = nameIndices
|
||||
self.rank = rank
|
||||
self.position = position
|
||||
}
|
||||
}
|
||||
|
||||
public enum SearchLimits {
|
||||
/// Content search starts at two characters; the in-file column at one.
|
||||
public static let minContentQuery = 2
|
||||
public static let maxFiles = 400
|
||||
public static let maxLineLength = 1000
|
||||
public static let maxHitsPerFile = 50
|
||||
public static let maxFileNameResults = 40
|
||||
public static let maxInFileResults = 200
|
||||
public static let maxExtensionChips = 12
|
||||
/// Keystroke debounce before a content search runs.
|
||||
public static let debounceMilliseconds = 120
|
||||
}
|
||||
Reference in New Issue
Block a user