**Describe the bug**
I created a new project with `cargo new foo`, opened it in… Nova, and began editing the main.rs file. And the language server keeps crashing on every edit. I restart it, it looks fine, I edit the file, crash.
<details><summary>Crash log</summary>
```
Rust Analyzer[11:13:31.012000] waiting for cargo metadata or cargo check
Rust Analyzer[11:13:31.705000] waiting for cargo metadata or cargo check
Rust Analyzer[11:13:31.754000] waiting for cargo metadata or cargo check
Rust Analyzer[11:13:32.545000] content modified
Rust Analyzer[11:13:33.574000] canceled by client
Rust Analyzer[11:13:36.553000] canceled by client
Rust Analyzer[11:13:36.670000] canceled by client
Rust Analyzer[11:13:45.842000] Panic context:
Rust Analyzer[11:13:45.842000] >
Rust Analyzer[11:13:45.842000] version: ed4b312fa 2021-10-11 stable
Rust Analyzer[11:13:45.842000] request: textDocument/codeAction CodeActionParams {
Rust Analyzer[11:13:45.842000] text_document: TextDocumentIdentifier {
Rust Analyzer[11:13:45.842000] uri: Url {
Rust Analyzer[11:13:45.842000] scheme: "file",
Rust Analyzer[11:13:45.842000] cannot_be_a_base: false,
Rust Analyzer[11:13:45.842000] username: "",
Rust Analyzer[11:13:45.842000] password: None,
Rust Analyzer[11:13:45.842000] host: None,
Rust Analyzer[11:13:45.842000] port: None,
Rust Analyzer[11:13:45.842000] path: "/Volumes/Macintosh%20HD/Users/lily/Desktop/foo/src/main.rs",
Rust Analyzer[11:13:45.842000] query: None,
Rust Analyzer[11:13:45.842000] fragment: None,
Rust Analyzer[11:13:45.842000] },
Rust Analyzer[11:13:45.842000] },
Rust Analyzer[11:13:45.842000] range: Range {
Rust Analyzer[11:13:45.842000] start: Position {
Rust Analyzer[11:13:45.842000] line: 5,
Rust Analyzer[11:13:45.842000] character: 0,
Rust Analyzer[11:13:45.842000] },
Rust Analyzer[11:13:45.842000] end: Position {
Rust Analyzer[11:13:45.842000] line: 5,
Rust Analyzer[11:13:45.842000] character: 0,
Rust Analyzer[11:13:45.842000] },
Rust Analyzer[11:13:45.842000] },
Rust Analyzer[11:13:45.842000] context: CodeActionContext {
Rust Analyzer[11:13:45.842000] diagnostics: [],
Rust Analyzer[11:13:45.842000] only: None,
Rust Analyzer[11:13:45.842000] },
Rust Analyzer[11:13:45.842000] work_done_progress_params: WorkDoneProgressParams {
Rust Analyzer[11:13:45.842000] work_done_token: None,
Rust Analyzer[11:13:45.842000] },
Rust Analyzer[11:13:45.842000] partial_result_params: PartialResultParams {
Rust Analyzer[11:13:45.842000] partial_result_token: None,
Rust Analyzer[11:13:45.842000] },
Rust Analyzer[11:13:45.842000] }
Rust Analyzer[11:13:45.842000]
Rust Analyzer[11:13:45.842000] thread '<unnamed>' panicked at 'index out of bounds: the len is 5 but the index is 5', crates/ide_db/src/line_index.rs:106:9
Rust Analyzer[11:13:45.842000] stack backtrace:
Rust Analyzer[11:13:45.843000] Panic context:
Rust Analyzer[11:13:45.843000] >
Rust Analyzer[11:13:45.843000] version: ed4b312fa 2021-10-11 stable
Rust Analyzer[11:13:45.843000] request: textDocument/completion CompletionParams {
Rust Analyzer[11:13:45.843000] text_document_position: TextDocumentPositionParams {
Rust Analyzer[11:13:45.843000] text_document: TextDocumentIdentifier {
Rust Analyzer[11:13:45.843000] uri: Url {
Rust Analyzer[11:13:45.843000] scheme: "file",
Rust Analyzer[11:13:45.843000] cannot_be_a_base: false,
Rust Analyzer[11:13:45.843000] username: "",
Rust Analyzer[11:13:45.843000] password: None,
Rust Analyzer[11:13:45.843000] host: None,
Rust Analyzer[11:13:45.843000] port: None,
Rust Analyzer[11:13:45.843000] path: "/Volumes/Macintosh%20HD/Users/lily/Desktop/foo/src/main.rs",
Rust Analyzer[11:13:45.843000] query: None,
Rust Analyzer[11:13:45.843000] fragment: None,
Rust Analyzer[11:13:45.843000] },
Rust Analyzer[11:13:45.843000] },
Rust Analyzer[11:13:45.843000] position: Position {
Rust Analyzer[11:13:45.843000] line: 5,
Rust Analyzer[11:13:45.843000] character: 0,
Rust Analyzer[11:13:45.843000] },
Rust Analyzer[11:13:45.843000] },
Rust Analyzer[11:13:45.843000] work_done_progress_params: WorkDoneProgressParams {
Rust Analyzer[11:13:45.843000] work_done_token: None,
Rust Analyzer[11:13:45.843000] },
Rust Analyzer[11:13:45.843000] partial_result_params: PartialResultParams {
Rust Analyzer[11:13:45.843000] partial_result_token: None,
Rust Analyzer[11:13:45.843000] },
Rust Analyzer[11:13:45.843000] context: Some(
Rust Analyzer[11:13:45.843000] CompletionContext {
Rust Analyzer[11:13:45.843000] trigger_kind: TriggerCharacter,
Rust Analyzer[11:13:45.843000] trigger_character: Some(
Rust Analyzer[11:13:45.843000] "f",
Rust Analyzer[11:13:45.843000] ),
Rust Analyzer[11:13:45.843000] },
Rust Analyzer[11:13:45.843000] ),
Rust Analyzer[11:13:45.843000] }
Rust Analyzer[11:13:45.843000]
Rust Analyzer[11:13:45.843000] thread '<unnamed>' panicked at 'index out of bounds: the len is 5 but the index is 5', crates/ide_db/src/line_index.rs:106:9
Rust Analyzer[11:13:45.854000] 0: _rust_begin_unwind
Rust Analyzer[11:13:45.854000] 1: core::panicking::panic_fmt
Rust Analyzer[11:13:45.854000] 2: core::panicking::panic_bounds_check
Rust Analyzer[11:13:45.854000] 3: rust_analyzer::from_proto::text_range
Rust Analyzer[11:13:45.854000] 4: rust_analyzer::from_proto::file_range
Rust Analyzer[11:13:45.854000] 5: rust_analyzer::handlers::handle_code_action
Rust Analyzer[11:13:45.854000] 6: std::panicking::try
Rust Analyzer[11:13:45.854000] 7: <F as threadpool::FnBox>::call_box
Rust Analyzer[11:13:45.854000] note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Rust Analyzer[11:13:45.854000] stack backtrace:
Rust Analyzer[11:13:45.854000] 0: _rust_begin_unwind
Rust Analyzer[11:13:45.854000] 1: core::panicking::panic_fmt
Rust Analyzer[11:13:45.854000] 2: core::panicking::panic_bounds_check
Rust Analyzer[11:13:45.854000] 3: rust_analyzer::from_proto::file_position
Rust Analyzer[11:13:45.854000] 4: rust_analyzer::handlers::handle_completion
Rust Analyzer[11:13:45.854000] 5: std::panicking::try
Rust Analyzer[11:13:45.854000] 6: <F as threadpool::FnBox>::call_box
Rust Analyzer[11:13:45.854000] note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Rust Analyzer[11:13:45.855000] server panicked: index out of bounds: the len is 5 but the index is 5
Rust Analyzer[11:13:45.855000] server panicked: index out of bounds: the len is 5 but the index is 5
Rust Analyzer[11:13:46.012000] Panic context:
Rust Analyzer[11:13:46.012000] >
Rust Analyzer[11:13:46.012000] version: ed4b312fa 2021-10-11 stable
Rust Analyzer[11:13:46.012000] notification: textDocument/didChange
Rust Analyzer[11:13:46.012000]
Rust Analyzer[11:13:46.012000] thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 5', crates/ide_db/src/line_index.rs:106:9
Rust Analyzer[11:13:46.012000] stack backtrace:
Rust Analyzer[11:13:46.012000] 0: _rust_begin_unwind
Rust Analyzer[11:13:46.012000] 1: core::panicking::panic_fmt
Rust Analyzer[11:13:46.012000] 2: core::panicking::panic_bounds_check
Rust Analyzer[11:13:46.012000] 3: rust_analyzer::from_proto::text_range
Rust Analyzer[11:13:46.012000] 4: rust_analyzer::lsp_utils::apply_document_changes
Rust Analyzer[11:13:46.012000] 5: core::ops::function::FnOnce::call_once
Rust Analyzer[11:13:46.012000] 6: rust_analyzer::dispatch::NotificationDispatcher::on
Rust Analyzer[11:13:46.012000] 7: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event
Rust Analyzer[11:13:46.012000] 8: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
Rust Analyzer[11:13:46.012000] 9: rust_analyzer::main_loop::main_loop
Rust Analyzer[11:13:46.012000] 10: rust_analyzer::try_main
Rust Analyzer[11:13:46.012000] 11: rust_analyzer::main
Rust Analyzer[11:13:46.012000] note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Rust Analyzer[11:13:46.012000] thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/lsp-server-0.5.2/src/stdio.rs:29:37
Rust Analyzer[11:13:46.012000] stack backtrace:
Rust Analyzer[11:13:46.012000] 0: _rust_begin_unwind
Rust Analyzer[11:13:46.012000] 1: core::panicking::panic_fmt
Rust Analyzer[11:13:46.012000] 2: core::result::unwrap_failed
Rust Analyzer[11:13:46.012000] note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Rust[11:13:46.329000] Error: Task “rust” exited with a non-zero exit status: 101.
```
</details>
**To Reproduce**
Steps to reproduce the behavior:
1. `cargo new foo` in the terminal
2. Drag the new `foo` folder into Nova
3. Open `src/main.rs`
4. Edit the file
**Additional information**
I haven't attempted to reproduce this with a fresh project.
In addition, after collecting that log, I cleared the console, opted to Restart Server, and then noticed that every cursor movement would log another panic (but would not tell me that the language server crashed). Hitting Save informed me of the crash again. I hit Restart Server again, and got
```
Rust Analyzer[11:18:54.454000] waiting for cargo metadata or cargo check
Rust Analyzer[11:18:56.002000] content modified
```
At this point every time I moved the cursor I'd get a line like
```
Rust Analyzer[11:18:56.878000] canceled by client
```
I hit Save again and this time it finally showed
```
Rust[11:19:05.080000] Checking foo v0.1.0 (/Users/lily/Desktop/foo)
Rust[11:19:05.237000] Finished dev [unoptimized + debuginfo] target(s) in 0.15s
```
Once I saw that, moving the cursor no longer logged anything, and I was able to make a trivial edit without logging too.
However, while writing up this report, after having left it alone for a while, I went back to Nova and inserted a single space at the end of the file, at which point the language server promptly crashed again.
**Versions (please complete the following information):**
- macOS: macOS 11.6 (20G165)
- Processor: Intel
- Nova 7.5
- Extension Version 1.0.3