Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting language in scratch buffer causes panic #1994

Closed
zen3ger opened this issue Apr 6, 2022 · 0 comments · Fixed by #1996
Closed

Setting language in scratch buffer causes panic #1994

zen3ger opened this issue Apr 6, 2022 · 0 comments · Fixed by #1996
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@zen3ger
Copy link
Contributor

zen3ger commented Apr 6, 2022

Summary

When using a scratch buffer it is not possible to use :lang or :set-language as it refreshes the language server which assumes that there's a document URL, which results in a panic.

// from Editor::launch_language_server
tokio::spawn(language_server.text_document_did_open(
    doc.url().unwrap(),  // <--
    doc.version(),
    doc.text(),
    language_id,
));

note: It's partially my fault as I haven't checked this when I implemented #1866, but I've come across it today as I was trying to just grab a snippet and highlight it to make sense of it...

Reproduction Steps

I tried this:

  1. hx
  2. type some code to the scratch buffer
  3. :lang rust

I expected this to happen:
Highlight the code and reload the language server.

Instead, this happened:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', helix-view/src/editor.rs:479:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Helix log

No response

Platform

FreeBSD

Terminal Emulator

alacritty

Helix Version

helix 22.05-dev (b03421a)

Edit: originally said "assumes that there's a document id", changed "id" to "URL".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants