File tree Expand file tree Collapse file tree 2 files changed +25
-12
lines changed Expand file tree Collapse file tree 2 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -265,20 +265,30 @@ impl CursorCrtl {
265
265
}
266
266
267
267
pub fn move_left ( & mut self , count : u16 ) -> io:: Result < ( ) > {
268
- let result = match self . x {
269
- x if x == 0 => Ok ( ( ) ) ,
270
- x if x < count => self . move_to_columu ( 0 ) ,
271
- x => match self . prefix_mode {
272
- true if x == self . line_prefix_width - 1 => Ok ( ( ) ) ,
273
- true if x - count < self . line_prefix_width => self . move_to_columu ( 0 ) ,
274
- _ => {
275
- self . x -= count;
276
- self . move_to_columu ( x - count)
277
- }
278
- } ,
268
+ // 如果当前光标位置小于或等于行前缀宽度,或者移动的距离大于当前光标位置,则直接移动到行前缀末尾
269
+ if self . x <= self . line_prefix_width || count > self . x {
270
+ return self . move_to_columu ( 0 ) ;
271
+ }
272
+
273
+ // 如果启用了前缀模式且光标在前缀区域内,不进行移动
274
+ if self . prefix_mode && self . x <= self . line_prefix_width {
275
+ return Ok ( ( ) ) ;
276
+ }
277
+
278
+ // 计算实际移动的距离
279
+ let actual_move = if count > self . x - self . line_prefix_width {
280
+ self . x - self . line_prefix_width
281
+ } else {
282
+ count
279
283
} ;
280
284
281
- result
285
+ // 执行光标左移操作
286
+ CursorManager :: move_left ( actual_move) ?;
287
+
288
+ // 更新光标位置
289
+ self . x -= actual_move;
290
+
291
+ Ok ( ( ) )
282
292
}
283
293
284
294
pub fn move_right ( & mut self , count : u16 ) -> io:: Result < ( ) > {
Original file line number Diff line number Diff line change @@ -385,6 +385,9 @@ impl Ui {
385
385
386
386
fn ui_exit ( & self ) {
387
387
// 处理未保存退出时的提醒
388
+
389
+ // 解决退出程序后颜色没改变的问题
390
+ StyleManager :: reset_color ( ) . unwrap ( ) ;
388
391
}
389
392
}
390
393
You can’t perform that action at this time.
0 commit comments