Fix bug with lists

This commit is contained in:
ef3d0c3e 2024-12-01 14:18:38 +01:00
parent decac73fec
commit de983979c4
3 changed files with 18 additions and 17 deletions

View file

@ -340,6 +340,20 @@ impl Rule for ListRule {
}
}
if let Some(hints) =
Hints::from_source(cursor.source.clone(), &state.shared.lsp)
{
let mut label = String::new();
for (_, id) in &depth
{
if !label.is_empty() {
label.push('.');
}
label.push_str(id.to_string().as_str());
}
hints.add(captures.get(1).unwrap().end(), label);
}
// Content
let entry_start = captures.get(3).unwrap().start();
let mut entry_content = captures.get(3).unwrap().as_str().to_string();
@ -396,20 +410,6 @@ impl Rule for ListRule {
ListRule::push_markers(&token, state, document, &vec![], &depth);
}
if let Some(hints) =
Hints::from_source(token.source(), &state.shared.lsp)
{
let mut label = String::new();
for (_, id) in &depth
{
if !label.is_empty() {
label.push('.');
}
label.push_str(id.to_string().as_str());
}
hints.add(captures.get(1).unwrap().end(), label);
}
state.push(
document,
Box::new(ListEntry {

View file

@ -590,7 +590,7 @@ nml.section.push("6", 6, "", "refname")
section_name { delta_line == 0, delta_start == 1 };
section_heading { delta_line == 1, delta_start == 0, length == 2 };
section_reference { delta_line == 0, delta_start == 2, length == 3 };
section_reference { delta_line == 0, delta_start == 2, length == 4 };
section_kind { delta_line == 0, delta_start == 4, length == 1 };
section_name { delta_line == 0, delta_start == 1 };

View file

@ -1,3 +1,4 @@
use std::borrow::BorrowMut;
use std::cell::RefCell;
use std::rc::Rc;
@ -53,9 +54,9 @@ fn from_source_impl(
return from_source_impl(location.source(), target, lsp, original);
} else if let Ok(sourcefile) = source.downcast_rc::<SourceFile>() {
let borrow = lsp.as_ref().unwrap().borrow();
let definitions = borrow.definitions.get(&original.source()).unwrap();
let mut db = definitions.definitions.borrow_mut();
if let Some(def_data) = borrow.definitions.get(&original.source())
{
let mut db = def_data.definitions.borrow_mut();
let token = original.source().original_range(original.range).1;
// Resolve target