diff --git a/Cargo.lock b/Cargo.lock index adf3643f..d0b30fa6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", ] diff --git a/core/src/buffer.rs b/core/src/buffer.rs index db7e6eca..5bd6a10a 100644 --- a/core/src/buffer.rs +++ b/core/src/buffer.rs @@ -3040,4 +3040,4 @@ pub fn grapheme_column_width(s: &str) -> usize { } } UnicodeWidthStr::width(s) -} \ No newline at end of file +} diff --git a/core/src/editor.rs b/core/src/editor.rs index b99f5f1b..5fd5a73e 100644 --- a/core/src/editor.rs +++ b/core/src/editor.rs @@ -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), ); } diff --git a/proxy/src/dispatch.rs b/proxy/src/dispatch.rs index bbdf91de..8d550de7 100644 --- a/proxy/src/dispatch.rs +++ b/proxy/src/dispatch.rs @@ -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": {