rust/crates
bors 8e581ac348 Auto merge of #17003 - krobelus:utf8-positions-multibyte, r=Veykril
Fix off-by-one error converting to LSP UTF8 offsets with multi-byte char

On this file,

```rust
fn main() {
    let 된장 = 1;
}
```

when using `"positionEncodings":["utf-16"]` I get an "unused variable" diagnostic on the variable
name (codepoint offset range `8..10`). So far so good.

When using `positionEncodings":["utf-8"]`, I expect to get the equivalent range in bytes (LSP:
"Character offsets count UTF-8 code units (e.g bytes)."), which is `8..14`, because both
characters are 3 bytes in UTF-8.  However I actually get `10..14`.

Looks like this is because we accidentally treat a 1-based index as an offset value: when
converting from our internal char-indices to LSP byte offsets, we look at one character to many.
This causes wrong results if the extra character is a multi-byte one, such as when computing
the start coordinate of 된장.

Fix that by actually passing an offset. While at it, fix the variable name of the line number,
which is not an offset (yet).

Originally reported at https://github.com/kakoune-lsp/kakoune-lsp/issues/740
2024-04-03 14:58:16 +00:00
..
base-db Rename ProcMacroKind::FuncLike to Bang 2024-03-22 11:20:56 +01:00
cfg
flycheck internal: Enforce utf8 paths 2024-03-19 15:39:00 +01:00
hir Consider ADT generic parameter defaults for unsubstituted layout calculations 2024-04-03 09:01:27 +02:00
hir-def Fix some cfg censoring bugs 2024-04-03 16:43:08 +02:00
hir-expand Fix some cfg censoring bugs 2024-04-03 16:43:08 +02:00
hir-ty Consider ADT generic parameter defaults for unsubstituted layout calculations 2024-04-03 09:01:27 +02:00
ide Consider ADT generic parameter defaults for unsubstituted layout calculations 2024-04-03 09:01:27 +02:00
ide-assists Adjust display impls to respect lifetime bounds 2024-04-02 14:51:08 +02:00
ide-completion Fix some cfg censoring bugs 2024-04-03 16:43:08 +02:00
ide-db Split SymbolKind::Function into Function and Method 2024-03-17 11:07:22 +01:00
ide-diagnostics Make use of ThinArc in RawAttrs 2024-03-21 11:49:09 +01:00
ide-ssr
intern Fix new clippy lints 2024-04-01 17:55:56 +02:00
limit
load-cargo Rename ProcMacroKind::FuncLike to Bang 2024-03-22 11:20:56 +01:00
mbe internal: Remove span trait 2024-03-21 20:08:30 +01:00
parser fix: Improve error recovery for match arms 2024-03-19 10:55:47 +01:00
paths fix: Don't assert paths being utf8 when filtering them in the watcher 2024-03-22 08:04:50 +01:00
proc-macro-api Consider ADT generic parameter defaults for unsubstituted layout calculations 2024-04-03 09:01:27 +02:00
proc-macro-srv Rename ProcMacroKind::FuncLike to Bang 2024-03-22 11:20:56 +01:00
proc-macro-srv-cli
profile
project-model Fix patch_cfg_if not applying with stitched sysroot 2024-04-02 15:04:40 +02:00
rust-analyzer Fix off-by-one error converting to LSP UTF8 offsets with multi-byte char 2024-04-03 14:46:51 +02:00
salsa Fix new clippy lints 2024-04-01 17:55:56 +02:00
sourcegen Fix new clippy lints 2024-04-01 17:55:56 +02:00
span Move Edition into span crate 2024-03-21 10:21:44 +01:00
stdx
syntax internal: Move grammar codegen into xtask 2024-03-19 10:57:53 +01:00
test-fixture Rename ProcMacroKind::FuncLike to Bang 2024-03-22 11:20:56 +01:00
test-utils Fix new clippy lints 2024-04-01 17:55:56 +02:00
text-edit
toolchain internal: Enforce utf8 paths 2024-03-19 15:39:00 +01:00
tt internal: Remove span trait 2024-03-21 20:08:30 +01:00
vfs fix: Some file watching related vfs fixes 2024-03-21 21:22:19 +01:00
vfs-notify fix: Don't assert paths being utf8 when filtering them in the watcher 2024-03-22 08:04:50 +01:00