fix crash by rope bytes
This commit is contained in:
parent
a749580bdb
commit
d903f37e73
@ -768,7 +768,8 @@ impl LSPSupport for Rope {
|
|||||||
}
|
}
|
||||||
fn byte_to_pos(&self, byte_idx: usize) -> Position {
|
fn byte_to_pos(&self, byte_idx: usize) -> Position {
|
||||||
// info!("byte_idx: {byte_idx}");
|
// info!("byte_idx: {byte_idx}");
|
||||||
return self.char_to_pos(self.byte_to_char(min(byte_idx, self.len_bytes() - 1)));
|
let self_len = if self.len_bytes() != 0 { self.len_bytes() - 1 } else { 0 };
|
||||||
|
return self.char_to_pos(self.byte_to_char(min(byte_idx, self_len)));
|
||||||
}
|
}
|
||||||
fn char_to_pos(&self, char_idx: usize) -> Position {
|
fn char_to_pos(&self, char_idx: usize) -> Position {
|
||||||
let line = self.char_to_line(char_idx);
|
let line = self.char_to_line(char_idx);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user