Skip to repository content48 lines · 1.4 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T06:56:27.657Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
keymap.rs
1use std::ops::Range;
2
3use tree_sitter::{Query, QueryMatch};
4
5use crate::MigrationPatterns;
6
7pub const KEYMAP_PATTERNS: MigrationPatterns =
8 &[(crate::patterns::KEYMAP_CONTEXT_PATTERN, rename_context_key)];
9
10fn rename_context_key(
11 contents: &str,
12 mat: &QueryMatch,
13 query: &Query,
14) -> Option<(Range<usize>, String)> {
15 let context_predicate_ix = query.capture_index_for_name("context_predicate")?;
16 let context_predicate_range = mat
17 .nodes_for_capture_index(context_predicate_ix)
18 .next()?
19 .byte_range();
20 let old_predicate = contents.get(context_predicate_range.clone())?.to_string();
21 let mut new_predicate = old_predicate.clone();
22
23 const REPLACEMENTS: &[(&str, &str)] = &[
24 (
25 "edit_prediction_conflict && !showing_completions",
26 "(edit_prediction && in_leading_whitespace)",
27 ),
28 (
29 "edit_prediction_conflict && showing_completions",
30 "(edit_prediction && showing_completions)",
31 ),
32 (
33 "edit_prediction_conflict",
34 "(edit_prediction && (showing_completions || in_leading_whitespace))",
35 ),
36 ];
37
38 for (old, new) in REPLACEMENTS {
39 new_predicate = new_predicate.replace(old, new);
40 }
41
42 if new_predicate != old_predicate {
43 Some((context_predicate_range, new_predicate))
44 } else {
45 None
46 }
47}
48