mirror of
https://github.com/nushell/nushell.git
synced 2025-05-16 16:04:30 +02:00
fix(lsp): inlay hints span issue with user config scripts (#15071)
# Description Fixes this:  # User-Facing Changes # Tests + Formatting I can't figure out how to test this atm. Happy to do it if someone show me some hints how. # After Submitting
This commit is contained in:
parent
a7830ac1fd
commit
c6fc6bd5a7
@ -160,6 +160,7 @@ impl LanguageServer {
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO: test for files loaded as user config
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::path_to_uri;
|
||||
|
@ -880,7 +880,9 @@ impl EngineState {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn files(&self) -> impl Iterator<Item = &CachedFile> {
|
||||
pub fn files(
|
||||
&self,
|
||||
) -> impl DoubleEndedIterator<Item = &CachedFile> + ExactSizeIterator<Item = &CachedFile> {
|
||||
self.files.iter()
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,15 @@ impl<'a> StateWorkingSet<'a> {
|
||||
}
|
||||
|
||||
pub fn get_span_for_filename(&self, filename: &str) -> Option<Span> {
|
||||
let file_id = self.files().position(|file| &*file.name == filename)?;
|
||||
let predicate = |file: &CachedFile| &*file.name == filename;
|
||||
// search from end to start, in case there're duplicated files with the same name
|
||||
let file_id = self
|
||||
.delta
|
||||
.files
|
||||
.iter()
|
||||
.rposition(predicate)
|
||||
.map(|idx| idx + self.permanent_state.num_files())
|
||||
.or_else(|| self.permanent_state.files().rposition(predicate))?;
|
||||
let file_id = FileId::new(file_id);
|
||||
|
||||
Some(self.get_span_for_file(file_id))
|
||||
|
Loading…
Reference in New Issue
Block a user