mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Make utf8 default, implement utf16 in terms of it
This commit is contained in:
parent
00cc778c8c
commit
95209aa3f8
6 changed files with 28 additions and 11 deletions
|
@ -5,7 +5,7 @@ use std::{env, path::PathBuf, str::FromStr, sync::Arc, time::Instant};
|
|||
use anyhow::{bail, format_err, Result};
|
||||
use hir::PrefixKind;
|
||||
use ide::{
|
||||
Analysis, AnalysisHost, Change, CompletionConfig, DiagnosticsConfig, FilePosition, LineColUtf16,
|
||||
Analysis, AnalysisHost, Change, CompletionConfig, DiagnosticsConfig, FilePosition, LineCol,
|
||||
};
|
||||
use ide_db::{
|
||||
base_db::{
|
||||
|
@ -97,7 +97,7 @@ impl BenchCmd {
|
|||
let offset = host
|
||||
.analysis()
|
||||
.file_line_index(file_id)?
|
||||
.offset(LineColUtf16 { line: pos.line - 1, col: pos.column });
|
||||
.offset(LineCol { line: pos.line - 1, col: pos.column });
|
||||
let file_position = FilePosition { file_id, offset };
|
||||
|
||||
if is_completion {
|
||||
|
|
|
@ -19,6 +19,7 @@ pub(crate) fn vfs_path(url: &lsp_types::Url) -> Result<vfs::VfsPath> {
|
|||
|
||||
pub(crate) fn offset(line_index: &LineIndex, position: lsp_types::Position) -> TextSize {
|
||||
let line_col = LineColUtf16 { line: position.line as u32, col: position.character as u32 };
|
||||
let line_col = line_index.to_utf8(line_col);
|
||||
line_index.offset(line_col)
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ use crate::{
|
|||
|
||||
pub(crate) fn position(line_index: &LineIndex, offset: TextSize) -> lsp_types::Position {
|
||||
let line_col = line_index.line_col(offset);
|
||||
let line_col = line_index.to_utf16(line_col);
|
||||
lsp_types::Position::new(line_col.line, line_col.col)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue