1package soy.iko.opencode.data.model
3import androidx.compose.runtime.Immutable
4import kotlinx.serialization.SerialName
5import kotlinx.serialization.Serializable
8 * One ripgrep match from `GET /find?pattern=` (content search). [path] and [lines] are
9 * wrapped `{ text }` objects on the wire; [submatches] carry the column offsets of each
10 * hit within the line so the UI can highlight them.
15 val path: TextField = TextField(),
16 val lines: TextField = TextField(),
17 @SerialName("line_number") val lineNumber: Int = 0,
18 @SerialName("absolute_offset") val absoluteOffset: Long = 0,
19 val submatches: List<SubMatch> = emptyList(),
23 data class TextField(val text: String = "")
32 /** The matched file's path (relative to the search root). */
33 val filePath: String get() = path.text
35 /** The matching line's text, trimmed of a trailing newline for display. */
36 val lineText: String get() = lines.text.trimEnd('\n', '\r')
40 * One workspace symbol from `GET /find/symbol?query=`. [kind] is the LSP `SymbolKind`
41 * integer; [location.uri] is a file URI and [location.range] the symbol's span.
45data class SymbolResult(
46 val name: String = "",
48 val location: Location = Location(),
54 val range: Range = Range(),
60 val start: Pos = Pos(),
68 val character: Int = 0,
71 /** The file path portion of [Location.uri], stripping a `file://` scheme when present. */
73 get() = location.uri.removePrefix("file://").ifBlank { location.uri }
75 /** 1-based line for display; the wire range is 0-based. */
76 val displayLine: Int get() = location.range.start.line + 1
79// LSP SymbolKind → label. A map lookup (rather than a large `when`) keeps the accessor
80// trivial. Indices follow the LSP SymbolKind enum.
81private val symbolKindLabels = mapOf(
82 1 to "file", 2 to "module", 3 to "namespace", 4 to "package", 5 to "class",
83 6 to "method", 7 to "property", 8 to "field", 9 to "constructor", 10 to "enum",
84 11 to "interface", 12 to "function", 13 to "variable", 14 to "constant", 15 to "string",
85 16 to "number", 17 to "boolean", 18 to "array", 19 to "object", 20 to "key",
86 22 to "enum member", 23 to "struct", 26 to "type",
89/** Human-readable label for an LSP [SymbolResult.kind]. */
90fun symbolKindLabel(kind: Int): String = symbolKindLabels[kind] ?: "symbol"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list