feat: handle enters in list or enum items (#1442)

* test: add tests about `onEnter`

* feat: handle enters in list or enum items
This commit is contained in:
Myriad-Dreamin 2025-03-05 12:30:47 +08:00 committed by GitHub
parent 78b80d41e4
commit f13b632ad2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 200 additions and 17 deletions

View file

@ -11,6 +11,7 @@ use std::{
use once_cell::sync::Lazy;
use serde_json::{ser::PrettyFormatter, Serializer, Value};
use tinymist_project::{CompileFontArgs, ExportTarget};
use tinymist_std::debug_loc::LspRange;
use tinymist_std::typst::TypstDocument;
use tinymist_world::package::PackageSpec;
use tinymist_world::vfs::WorkspaceResolver;
@ -203,7 +204,12 @@ pub fn run_with_sources<T>(source: &str, f: impl FnOnce(&mut LspUniverse, PathBu
f(&mut verse, pw)
}
pub fn find_test_range(s: &Source) -> Range<usize> {
pub fn find_test_range(s: &Source) -> LspRange {
let range = find_test_range_(s);
crate::to_lsp_range(range, s, PositionEncoding::Utf16)
}
pub fn find_test_range_(s: &Source) -> Range<usize> {
// /* range -3..-1 */
fn find_prefix(s: &str, sub: &str, left: bool) -> Option<(usize, usize, bool)> {
Some((s.find(sub)?, sub.len(), left))