mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 13:06:08 +02:00
lsp and --ide-check fix for path self
related diagnostics (#14538)
# Description fixes [this](https://github.com/nushell/nushell/pull/14303#issuecomment-2525100480) where lsp and ide integration would produce the following error --- ```sh nu --ide-check 100 "/path/to/env.nu" ``` with ```nu const const_env = path self ``` would lead to ``` Error: nu:🐚:file_not_found × File not found ╭─[/path/to/env.nu:1:19] 1 │ const const_env = path self · ────┬──── · ╰── Couldn't find current file ╰──── ``` # Tests + Formatting - 🟢 `cargo fmt --all` - 🟢 `cargo clippy --workspace`
This commit is contained in:
@ -7,7 +7,7 @@ use miette::{IntoDiagnostic, Result};
|
||||
use nu_parser::parse;
|
||||
use nu_protocol::{
|
||||
engine::{EngineState, StateWorkingSet},
|
||||
Value,
|
||||
Span, Value,
|
||||
};
|
||||
|
||||
impl LanguageServer {
|
||||
@ -28,6 +28,7 @@ impl LanguageServer {
|
||||
|
||||
let contents = rope_of_file.bytes().collect::<Vec<u8>>();
|
||||
let offset = working_set.next_span_start();
|
||||
working_set.files.push(file_path.into(), Span::unknown())?;
|
||||
parse(
|
||||
&mut working_set,
|
||||
Some(&file_path.to_string_lossy()),
|
||||
|
@ -274,6 +274,9 @@ impl LanguageServer {
|
||||
|
||||
// TODO: think about passing down the rope into the working_set
|
||||
let contents = file.bytes().collect::<Vec<u8>>();
|
||||
let _ = working_set
|
||||
.files
|
||||
.push(file_path.as_ref().into(), Span::unknown());
|
||||
let block = parse(working_set, Some(&file_path), &contents, false);
|
||||
let flattened = flatten_block(working_set, &block);
|
||||
|
||||
|
Reference in New Issue
Block a user