diff options
Diffstat (limited to 'crates/rust-analyzer/src/global_state.rs')
-rw-r--r-- | crates/rust-analyzer/src/global_state.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index c3bc8791d..52c249713 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs | |||
@@ -7,7 +7,7 @@ use std::{sync::Arc, time::Instant}; | |||
7 | 7 | ||
8 | use crossbeam_channel::{unbounded, Receiver, Sender}; | 8 | use crossbeam_channel::{unbounded, Receiver, Sender}; |
9 | use flycheck::FlycheckHandle; | 9 | use flycheck::FlycheckHandle; |
10 | use ide::{Analysis, AnalysisHost, Change, FileId}; | 10 | use ide::{Analysis, AnalysisHost, Cancelable, Change, FileId}; |
11 | use ide_db::base_db::{CrateId, VfsPath}; | 11 | use ide_db::base_db::{CrateId, VfsPath}; |
12 | use lsp_types::{SemanticTokens, Url}; | 12 | use lsp_types::{SemanticTokens, Url}; |
13 | use parking_lot::{Mutex, RwLock}; | 13 | use parking_lot::{Mutex, RwLock}; |
@@ -22,7 +22,7 @@ use crate::{ | |||
22 | diagnostics::{CheckFixes, DiagnosticCollection}, | 22 | diagnostics::{CheckFixes, DiagnosticCollection}, |
23 | document::DocumentData, | 23 | document::DocumentData, |
24 | from_proto, | 24 | from_proto, |
25 | line_endings::LineEndings, | 25 | line_index::{LineEndings, LineIndex}, |
26 | main_loop::Task, | 26 | main_loop::Task, |
27 | op_queue::OpQueue, | 27 | op_queue::OpQueue, |
28 | reload::SourceRootConfig, | 28 | reload::SourceRootConfig, |
@@ -271,8 +271,11 @@ impl GlobalStateSnapshot { | |||
271 | file_id_to_url(&self.vfs.read().0, id) | 271 | file_id_to_url(&self.vfs.read().0, id) |
272 | } | 272 | } |
273 | 273 | ||
274 | pub(crate) fn file_line_endings(&self, id: FileId) -> LineEndings { | 274 | pub(crate) fn file_line_index(&self, file_id: FileId) -> Cancelable<LineIndex> { |
275 | self.vfs.read().1[&id] | 275 | let endings = self.vfs.read().1[&file_id]; |
276 | let index = self.analysis.file_line_index(file_id)?; | ||
277 | let res = LineIndex { index, endings, encoding: self.config.offset_encoding() }; | ||
278 | Ok(res) | ||
276 | } | 279 | } |
277 | 280 | ||
278 | pub(crate) fn url_file_version(&self, url: &Url) -> Option<i32> { | 281 | pub(crate) fn url_file_version(&self, url: &Url) -> Option<i32> { |