diff options
author | Nathan Vegdahl | 2021-06-20 22:09:10 +0000 |
---|---|---|
committer | Nathan Vegdahl | 2021-06-20 22:33:02 +0000 |
commit | 4efd6713c5b30b33c497a1f85b77a7b0a7fd17e0 (patch) | |
tree | 7661f09f2279a3f9ae6a8f76770a69fd08f95981 /helix-lsp | |
parent | 5d22e3c4e574eb24260966de7f20f582e6184e24 (diff) |
Work on moving code over to LineEnding instead of assuming '\n'.
Also some general cleanup and some minor fixes along the way.
Diffstat (limited to 'helix-lsp')
-rw-r--r-- | helix-lsp/src/client.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 101d2f9b..7f136fe8 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -3,7 +3,7 @@ use crate::{ Call, Error, OffsetEncoding, Result, }; -use helix_core::{find_root, ChangeSet, Rope}; +use helix_core::{chars::char_is_line_ending, find_root, ChangeSet, Rope}; use jsonrpc_core as jsonrpc; use lsp_types as lsp; use serde_json::Value; @@ -337,8 +337,9 @@ impl Client { mut character, } = pos; - for ch in text.chars() { - if ch == '\n' { + let mut chars = text.chars().peekable(); + while let Some(ch) = chars.next() { + if char_is_line_ending(ch) && !(ch == '\r' && chars.peek() == Some(&'\n')) { line += 1; character = 0; } else { |