diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 00:03:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 00:03:29 -0300 |
| commit | 3a3601f984d25f1e03cee3ac47da7eeb2548e511 (patch) | |
| tree | 445331cb8ad346989c4e4f6a3ceff54411064e4a /core/Query.zig | |
| parent | 8a1f65a2d374796b9b5559c4aab87c8d1e8f6e68 (diff) | |
| parent | 528530ed065b2059d16b08efd92103d1dbbccc31 (diff) | |
| download | pardes-3a3601f984d25f1e03cee3ac47da7eeb2548e511.tar.gz pardes-3a3601f984d25f1e03cee3ac47da7eeb2548e511.zip | |
integration: a far client's seven small faults on the renamed tree: pardes-far-faults (a refocus that no longer asks the session's host about a newer build; a drag in a kind's pane grown too short; a draw's token that no rollback takes back; a text's declarations dumped so a joined client's query reads what the session's does; a search that goes on at once on a far client; two tests of what cannot happen) and pardes-merge24, merged without a textual conflict; the coordinator's gate in the ledger (reorg/merge25)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Query.zig')
| -rw-r--r-- | core/Query.zig | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/core/Query.zig b/core/Query.zig index 0cecb93e..704206e6 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -754,7 +754,7 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz const oid = owner_id orelse return; const owner = p.panes[oid].?; const f = if (owner.file) |*file| file else return; - const decls = ownerDecls(p, f, false) orelse { + const decls = ownerDecls(f) orelse { // Parsed on the worker; listed when it is done (declsArrived). Stream.parseFor(p, oid); return; @@ -782,31 +782,15 @@ fn recentRows(p: *Pardes, out: *std.Io.Writer.Allocating) []const u8 { return out.written(); } -/// The owner's declarations, from a parse that already exists: its sticky -/// headers' (TreeContext) at this revision, or the locations cache's. None -/// is made here, on the loop, unless `small` and the text is small: a -/// tree-sitter parse of a 1.2 MB file is seconds in a Debug build. -/// ponytail: no grouping for a big file until the disk engine's worker -/// parses it (phase 4). -fn ownerDecls(p: *Pardes, f: *File.State, small: bool) ?[]const syntax.ContextDeclaration { +/// The owner's declarations, from its parse at this revision (its context: +/// sticky headers' (TreeContext), a worker's answer, a dump's load), or +/// none: never the locations cache's (a Diff's), which a client joined +/// since has not, nor a parse made here (Stream.parseFor asks one). +fn ownerDecls(f: *const File.State) ?[]const syntax.ContextDeclaration { if (f.context.revision) |rev| if (rev == f.revision and f.context.declarations.len > 0) return f.context.declarations; - const cache = &p.locations_cache; - for (cache.entries[0..cache.len]) |entry| { - if (entry.declarations_ready and std.mem.eql(u8, entry.path, f.path) and std.mem.eql(u8, entry.source, f.content)) return entry.analysis.declarations; - } - if (!small or f.content.len > small_parse_bytes or !syntax.supportsPath(f.path)) return null; - var got = p.locations_cache.get(p.tree_sitter_gpa, f.path, f.content, true, false) catch return null; - if (got.owned) { - got.deinit(p.tree_sitter_gpa); - return null; - } - return got.analysis.declarations; + return null; } -/// A text this small is parsed on the loop for its declarations when a -/// Symbols query asks (about 40 ms in a Debug build). -const small_parse_bytes = 64 << 10; - /// The rows as `note` says, and nothing else: no hits. fn noteRows(p: *Pardes, id: usize, note: []const u8) void { const rp = p.panes[id].?; @@ -1043,7 +1027,7 @@ fn writePlacesRows(p: *Pardes, q: *Query, out: *std.ArrayList(u8), rows: *std.Ar const rel = lookPath(&relbuf, path, dir); const width = addressWidth(rel, index.len); var sh: Shades = .{}; - const decls = ownerDecls(p, f, false) orelse &.{}; + const decls = ownerDecls(f) orelse &.{}; var decl_now: ?usize = null; var i: usize = @min(from, hits.len); // the line of the first, found in the index @@ -1107,7 +1091,7 @@ fn makeTextRows(p: *Pardes, id: usize, oid: usize, full: bool) !void { var rows: std.ArrayList(locations.Row) = .empty; var budget: usize = if (full) max_rows else live_rows; // Grouped once a parse of the text exists: asked of the worker now. - if (ownerDecls(p, &owner.file.?, false) == null) Stream.parseFor(p, oid); + if (ownerDecls(&owner.file.?) == null) Stream.parseFor(p, oid); const at = set.current orelse (if (set.seek) |s| Places.firstFrom(set.hits.items, s) else 0); // While typed, a window of rows from just before the current place, so // it sits under line 1. |
