mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-23 12:45:04 +00:00
fix: search newline character in utf-8 bytes sequence (#299)
This commit is contained in:
parent
caaeb8efe8
commit
937f6f042f
1 changed files with 4 additions and 2 deletions
|
@ -138,7 +138,7 @@ pub fn get_deref_target(node: LinkedNode, cursor: usize) -> Option<DerefTarget<'
|
|||
}
|
||||
|
||||
// Get the trivia text before the cursor.
|
||||
let pref = node.text();
|
||||
let pref = node.text().as_bytes();
|
||||
let pref = if node.range().contains(&cursor) {
|
||||
&pref[..cursor - node.offset()]
|
||||
} else {
|
||||
|
@ -146,8 +146,10 @@ pub fn get_deref_target(node: LinkedNode, cursor: usize) -> Option<DerefTarget<'
|
|||
};
|
||||
|
||||
// The deref target should be on the same line as the cursor.
|
||||
// Assuming the underlying text is utf-8 encoded, we can check for newlines by
|
||||
// looking for b'\n'.
|
||||
// todo: if we are in markup mode, we should check if we are at start of node
|
||||
!pref.contains('\n')
|
||||
!pref.contains(&b'\n')
|
||||
}
|
||||
|
||||
// Move to the first non-trivia node before the cursor.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue