mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Rename col to col_utf16
This commit is contained in:
parent
136d1864bc
commit
bccbee5ba3
2 changed files with 28 additions and 23 deletions
|
@ -51,7 +51,7 @@ impl ConvWith for Position {
|
|||
fn conv_with(self, line_index: &LineIndex) -> TextUnit {
|
||||
let line_col = LineCol {
|
||||
line: self.line as u32,
|
||||
col: (self.character as u32).into(),
|
||||
col_utf16: self.character as u32,
|
||||
};
|
||||
line_index.offset(line_col)
|
||||
}
|
||||
|
@ -63,7 +63,10 @@ impl ConvWith for TextUnit {
|
|||
|
||||
fn conv_with(self, line_index: &LineIndex) -> Position {
|
||||
let line_col = line_index.line_col(self);
|
||||
Position::new(u64::from(line_col.line), u64::from(u32::from(line_col.col)))
|
||||
Position::new(
|
||||
u64::from(line_col.line),
|
||||
u64::from(u32::from(line_col.col_utf16)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,8 +204,10 @@ impl TryConvWith for SourceChange {
|
|||
.map(|it| it.edits.as_slice())
|
||||
.unwrap_or(&[]);
|
||||
let line_col = translate_offset_with_edit(&*line_index, pos.offset, edits);
|
||||
let position =
|
||||
Position::new(u64::from(line_col.line), u64::from(u32::from(line_col.col)));
|
||||
let position = Position::new(
|
||||
u64::from(line_col.line),
|
||||
u64::from(u32::from(line_col.col_utf16)),
|
||||
);
|
||||
Some(TextDocumentPositionParams {
|
||||
text_document: TextDocumentIdentifier::new(pos.file_id.try_conv_with(world)?),
|
||||
position,
|
||||
|
@ -245,12 +250,12 @@ fn translate_offset_with_edit(
|
|||
if in_edit_line_col.line == 0 {
|
||||
LineCol {
|
||||
line: edit_line_col.line,
|
||||
col: edit_line_col.col + in_edit_line_col.col,
|
||||
col_utf16: edit_line_col.col_utf16 + in_edit_line_col.col_utf16,
|
||||
}
|
||||
} else {
|
||||
LineCol {
|
||||
line: edit_line_col.line + in_edit_line_col.line,
|
||||
col: in_edit_line_col.col,
|
||||
col_utf16: in_edit_line_col.col_utf16,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue