mirror of https://github.com/lapce/lapce.git
cursor width on unicode char
This commit is contained in:
parent
dc58beaeea
commit
956fc2689f
|
@ -3205,6 +3205,7 @@ dependencies = [
|
|||
"font-kit",
|
||||
"futures",
|
||||
"glam",
|
||||
"include_dir",
|
||||
"linked-hash-map",
|
||||
"lyon",
|
||||
"pathfinder_geometry",
|
||||
|
@ -3212,6 +3213,7 @@ dependencies = [
|
|||
"raw-window-handle",
|
||||
"rustc-hash",
|
||||
"sha2 0.9.8",
|
||||
"unicode-width",
|
||||
"usvg",
|
||||
"wgpu",
|
||||
]
|
||||
|
|
|
@ -3040,4 +3040,4 @@ pub fn grapheme_column_width(s: &str) -> usize {
|
|||
}
|
||||
}
|
||||
UnicodeWidthStr::width(s)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
use std::{cmp::Ordering, iter::Iterator, path::PathBuf};
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use std::{str::FromStr, time::Duration};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
use xi_core_lib::selection::InsertDrift;
|
||||
use xi_rope::{Interval, RopeDelta};
|
||||
|
||||
|
@ -1193,13 +1194,23 @@ fn paint_cursor(
|
|||
|
||||
if active {
|
||||
let cursor_x = col as f64 * width;
|
||||
let next = data.buffer.next_grapheme_offset(
|
||||
*offset,
|
||||
1,
|
||||
data.buffer.len(),
|
||||
);
|
||||
let char = data.buffer.slice_to_cow(*offset..next).to_string();
|
||||
let char_width = UnicodeWidthStr::width(char.as_str()).max(1);
|
||||
ctx.fill(
|
||||
Rect::ZERO
|
||||
.with_origin(Point::new(
|
||||
cursor_x,
|
||||
line as f64 * line_height,
|
||||
))
|
||||
.with_size(Size::new(width, line_height)),
|
||||
.with_size(Size::new(
|
||||
width * char_width as f64,
|
||||
line_height,
|
||||
)),
|
||||
&env.get(LapceTheme::EDITOR_CURSOR_COLOR),
|
||||
);
|
||||
}
|
||||
|
@ -1272,13 +1283,20 @@ fn paint_cursor(
|
|||
|
||||
let (line, col) = data.buffer.offset_to_line_col(*end);
|
||||
let cursor_x = col as f64 * width;
|
||||
let next =
|
||||
data.buffer.next_grapheme_offset(*end, 1, data.buffer.len());
|
||||
let char = data.buffer.slice_to_cow(*end..next).to_string();
|
||||
let char_width = UnicodeWidthStr::width(char.as_str()).max(1);
|
||||
ctx.fill(
|
||||
Rect::ZERO
|
||||
.with_origin(Point::new(
|
||||
cursor_x,
|
||||
line as f64 * line_height,
|
||||
))
|
||||
.with_size(Size::new(width, line_height)),
|
||||
.with_size(Size::new(
|
||||
width * char_width as f64,
|
||||
line_height,
|
||||
)),
|
||||
&env.get(LapceTheme::EDITOR_CURSOR_COLOR),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -294,7 +294,6 @@ pub fn start_update_process(
|
|||
if let Some((diff, line_changes)) =
|
||||
file_git_diff(&workspace, &PathBuf::from(path), &content)
|
||||
{
|
||||
eprintln!("diff {:?}", diff);
|
||||
self.sender.send(json!({
|
||||
"method": "update_git",
|
||||
"params": {
|
||||
|
|
Loading…
Reference in New Issue