feat: autofix unknown variable: a and file not found (searched at a.typ) by code action (#1743)

* feat: check context

* feat: implement it

* fix: warnings

* test: update snapshot
This commit is contained in:
Myriad-Dreamin 2025-05-09 23:44:12 +08:00 committed by GitHub
parent d6d3766b6f
commit 38974a3b5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 834 additions and 84 deletions

View file

@ -275,7 +275,7 @@ fn match_by_pos(mut n: LinkedNode, prev: bool, ident: bool) -> usize {
n.offset()
}
pub fn make_pos_annoation(source: &Source) -> (LspPosition, String) {
pub fn make_pos_annotation(source: &Source) -> (LspPosition, String) {
let pos = find_test_typst_pos(source);
let range_before = pos.saturating_sub(10)..pos;
let range_after = pos..pos.saturating_add(10).min(source.text().len());
@ -287,7 +287,7 @@ pub fn make_pos_annoation(source: &Source) -> (LspPosition, String) {
(pos, format!("{window_before}|{window_after}"))
}
pub fn make_range_annoation(source: &Source) -> String {
pub fn make_range_annotation(source: &Source) -> String {
let range = find_test_range_(source);
let range_before = range.start.saturating_sub(10)..range.start;
let range_window = range.clone();