Fix bug in styles
This commit is contained in:
parent
f99a51e73a
commit
34662e2049
6 changed files with 9 additions and 14 deletions
|
@ -14,7 +14,6 @@ use mlua::Function;
|
||||||
use mlua::Lua;
|
use mlua::Lua;
|
||||||
|
|
||||||
use crate::document::document::Document;
|
use crate::document::document::Document;
|
||||||
use crate::document::document::DocumentAccessors;
|
|
||||||
use crate::lua::kernel::KernelContext;
|
use crate::lua::kernel::KernelContext;
|
||||||
use crate::lua::kernel::CTX;
|
use crate::lua::kernel::CTX;
|
||||||
use crate::parser::customstyle::CustomStyle;
|
use crate::parser::customstyle::CustomStyle;
|
||||||
|
|
|
@ -212,7 +212,7 @@ impl RegexRule for StyleRule {
|
||||||
{
|
{
|
||||||
0 => styles.add(start.start()..token.end(), crate::lsp::styles::Style::Style("bold".into())),
|
0 => styles.add(start.start()..token.end(), crate::lsp::styles::Style::Style("bold".into())),
|
||||||
1 => styles.add(start.start()..token.end(), crate::lsp::styles::Style::Style("italic".into())),
|
1 => styles.add(start.start()..token.end(), crate::lsp::styles::Style::Style("italic".into())),
|
||||||
2 => styles.add(start.start()..token.end(), crate::lsp::styles::Style::Style("underlined".into())),
|
2 => styles.add(start.start()..token.end()-1, crate::lsp::styles::Style::Style("underlined".into())),
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,8 +110,8 @@ impl<'a> Conceals<'a> {
|
||||||
pub fn add(&self, range: Range<usize>, text: ConcealTarget) {
|
pub fn add(&self, range: Range<usize>, text: ConcealTarget) {
|
||||||
let range = self.original_source.original_range(range).1;
|
let range = self.original_source.original_range(range).1;
|
||||||
let mut cursor = self.conceals.cursor.borrow_mut();
|
let mut cursor = self.conceals.cursor.borrow_mut();
|
||||||
cursor.move_to(range.start);
|
|
||||||
|
|
||||||
|
cursor.move_to(range.start);
|
||||||
let line = cursor.line;
|
let line = cursor.line;
|
||||||
let start_char = cursor.line_pos;
|
let start_char = cursor.line_pos;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use std::borrow::BorrowMut;
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub struct StylesData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StylesData {
|
impl StylesData {
|
||||||
pub fn new(source: Rc<dyn Source>) -> Self {
|
pub fn new(_source: Rc<dyn Source>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
styles: RefCell::new(vec![]),
|
styles: RefCell::new(vec![]),
|
||||||
}
|
}
|
||||||
|
@ -99,24 +99,24 @@ impl<'a> Styles<'a> {
|
||||||
|
|
||||||
pub fn add(&self, range: Range<usize>, style: Style) {
|
pub fn add(&self, range: Range<usize>, style: Style) {
|
||||||
let range = self.original_source.original_range(range).1;
|
let range = self.original_source.original_range(range).1;
|
||||||
let mut cursor = LineCursor::new(self.original_source.clone());
|
let mut cursor = LineCursor::new(self.source.clone());
|
||||||
cursor.move_to(range.start);
|
|
||||||
|
|
||||||
let line = cursor.line;
|
cursor.move_to(range.start);
|
||||||
|
let start_line = cursor.line;
|
||||||
let start_char = cursor.line_pos;
|
let start_char = cursor.line_pos;
|
||||||
|
|
||||||
cursor.move_to(range.end);
|
cursor.move_to(range.end);
|
||||||
assert_eq!(line, cursor.line);
|
let end_line = cursor.line;
|
||||||
let end_char = cursor.line_pos;
|
let end_char = cursor.line_pos;
|
||||||
|
|
||||||
self.styles.styles.borrow_mut().push(StyleInfo {
|
self.styles.styles.borrow_mut().push(StyleInfo {
|
||||||
range: tower_lsp::lsp_types::Range {
|
range: tower_lsp::lsp_types::Range {
|
||||||
start: Position {
|
start: Position {
|
||||||
line: line as u32,
|
line: start_line as u32,
|
||||||
character: start_char as u32,
|
character: start_char as u32,
|
||||||
},
|
},
|
||||||
end: Position {
|
end: Position {
|
||||||
line: line as u32,
|
line: end_line as u32,
|
||||||
character: end_char as u32,
|
character: end_char as u32,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,10 +6,7 @@ use crate::document::document::Document;
|
||||||
use crate::document::element::DocumentEnd;
|
use crate::document::element::DocumentEnd;
|
||||||
use crate::document::langdocument::LangDocument;
|
use crate::document::langdocument::LangDocument;
|
||||||
use crate::elements::text::Text;
|
use crate::elements::text::Text;
|
||||||
use crate::lsp::definition::DefinitionData;
|
|
||||||
use crate::lsp::hints::HintsData;
|
|
||||||
use crate::lsp::semantic::Semantics;
|
use crate::lsp::semantic::Semantics;
|
||||||
use crate::lsp::semantic::SemanticsData;
|
|
||||||
|
|
||||||
use super::parser::ParseMode;
|
use super::parser::ParseMode;
|
||||||
use super::parser::Parser;
|
use super::parser::Parser;
|
||||||
|
|
Loading…
Reference in a new issue