更新结构
This commit is contained in:
parent
00ec7abc6c
commit
53b8ebaa1a
@ -455,31 +455,31 @@ pub trait LSPSupport {
|
||||
/// Extend ropey's Rope type with lsp convenience functions
|
||||
impl LSPSupport for Rope {
|
||||
fn pos_to_byte(&self, pos: &Position) -> usize {
|
||||
self.char_to_byte(self.pos_to_char(pos))
|
||||
return self.char_to_byte(self.pos_to_char(pos));
|
||||
}
|
||||
fn pos_to_char(&self, pos: &Position) -> usize {
|
||||
let line_slice = self.line(pos.line as usize);
|
||||
self.line_to_char(pos.line as usize) + line_slice.utf16_cu_to_char(pos.character as usize)
|
||||
return self.line_to_char(pos.line as usize) + line_slice.utf16_cu_to_char(pos.character as usize);
|
||||
}
|
||||
fn byte_to_pos(&self, byte_idx: usize) -> Position {
|
||||
self.char_to_pos(self.byte_to_char(min(byte_idx, self.len_bytes() - 1)))
|
||||
return self.char_to_pos(self.byte_to_char(min(byte_idx, self.len_bytes() - 1)));
|
||||
}
|
||||
fn char_to_pos(&self, char_idx: usize) -> Position {
|
||||
let line = self.char_to_line(char_idx);
|
||||
let line_slice = self.line(line);
|
||||
Position {
|
||||
return Position {
|
||||
line: line as u32,
|
||||
character: line_slice.char_to_utf16_cu(char_idx - self.line_to_char(line)) as u32,
|
||||
}
|
||||
};
|
||||
}
|
||||
fn range_to_char_range(&self, range: &Range) -> StdRange<usize> {
|
||||
self.pos_to_char(&range.start)..self.pos_to_char(&range.end)
|
||||
return self.pos_to_char(&range.start)..self.pos_to_char(&range.end);
|
||||
}
|
||||
fn char_range_to_range(&self, range: StdRange<usize>) -> Range {
|
||||
Range {
|
||||
return Range {
|
||||
start: self.char_to_pos(range.start),
|
||||
end: self.char_to_pos(range.end),
|
||||
}
|
||||
};
|
||||
}
|
||||
fn apply_change(&mut self, change: &TextDocumentContentChangeEvent) {
|
||||
if let Some(range) = change.range {
|
||||
|
Loading…
x
Reference in New Issue
Block a user