Skip to content

Commit

Permalink
Update lsp-types and hide character_to_line_offset
Browse files Browse the repository at this point in the history
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: gluon-lang/lsp-types#186

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

Co-authored-by: Johann150 <[email protected]>
  • Loading branch information
brendanzab and Johann150 committed Nov 29, 2020
1 parent 07d0801 commit c7f333e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions codespan-lsp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion codespan-lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 4 additions & 4 deletions codespan-lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit c7f333e

Please sign in to comment.