Update lsp-types and hide character_to_line_offset

We’ve broken backwards-compatability with old versions of lsp-types in order to let us update the LSP numeric types based on the numeric type clarifications: https://github.com/gluon-lang/lsp-types/pull/186

`character_to_line_offset` was made private to reduce the chance of future API breakages.

Co-authored-by: Johann150 <20990607+Johann150@users.noreply.github.com>
This commit is contained in:
Brendan Zabarauskas 2020-11-30 09:50:36 +11:00
parent 07d0801bca
commit c7f333e44f
3 changed files with 10 additions and 7 deletions

View File

@ -11,8 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The error type in `codespan-lsp` is replaced with the error type in the `codespan-reporting` crate.
The error type is now `codespan_reporting::file::Error`.
- The `lsp-types` dependency was updated to use a version range: `>=0.70, <0.83`,
which includes the latest updates in `0.82.0`.
- The `lsp-types` dependency was updated to use the version range: `>=0.84, <0.85`.
Compatibility was broken as a result of the [clarified numeric types] that this crate depended on.
- The `character_to_line_offset` function was made private to reduce the chance of future public breakages.
[clarified numeric types]: https://github.com/gluon-lang/lsp-types/pull/186
## [0.10.1] - 2020-08-17

View File

@ -16,5 +16,5 @@ codespan-reporting = { version = "0.9.5", path = "../codespan-reporting" }
# will be valid for all the versions in this range. Getting this range wrong
# could potentially break down-stream builds on a `cargo update`. This is an
# absolute no-no, breaking much of what we enjoy about Cargo!
lsp-types = ">=0.70, <0.83"
lsp-types = ">=0.84, <0.85"
url = "2"

View File

@ -27,8 +27,8 @@ fn location_to_position(
Err(Error::InvalidCharBoundary { given })
} else {
let line_utf16 = line_str[..column].encode_utf16();
let character = line_utf16.count() as u64;
let line = line as u64;
let character = line_utf16.count() as u32;
let line = line as u32;
Ok(LspPosition { line, character })
}
@ -77,7 +77,7 @@ where
})
}
pub fn character_to_line_offset(line: &str, character: u64) -> Result<usize, Error> {
fn character_to_line_offset(line: &str, character: u32) -> Result<usize, Error> {
let line_len = line.len();
let mut character_offset = 0;
@ -90,7 +90,7 @@ pub fn character_to_line_offset(line: &str, character: u64) -> Result<usize, Err
return Ok(line_len - chars_off - ch_off);
}
character_offset += ch.len_utf16() as u64;
character_offset += ch.len_utf16() as u32;
}
// Handle positions after the last character on the line