Skip to main content

rust_analyzer/
line_index.rs

1//! Enhances `ide::LineIndex` with additional info required to convert offsets
2//! into lsp positions.
3//!
4//! The VFS normalizes UTF-8 file contents to use `\n` as the line separator.
5//! We retain the detected line-ending convention here so outgoing LSP edits
6//! can restore `\r\n` when needed.
7
8use ide_db::line_index::WideEncoding;
9use triomphe::Arc;
10use vfs::LineEndings;
11
12#[derive(Clone, Copy)]
13pub enum PositionEncoding {
14    Utf8,
15    Wide(WideEncoding),
16}
17
18pub(crate) struct LineIndex {
19    pub(crate) index: Arc<ide::LineIndex>,
20    pub(crate) endings: LineEndings,
21    pub(crate) encoding: PositionEncoding,
22}