@@ -100,7 +100,7 @@ impl EditorView {
100
100
let mut decorations = DecorationManager :: default ( ) ;
101
101
102
102
if is_focused && config. cursorline {
103
- decorations. add_decoration ( Self :: cursorline ( doc, view, theme) ) ;
103
+ decorations. add_decoration ( Self :: cursorline ( doc, view, theme, & editor . mode ) ) ;
104
104
}
105
105
106
106
if is_focused && config. cursorcolumn {
@@ -236,15 +236,17 @@ impl EditorView {
236
236
Self :: render_diagnostics ( doc, view, inner, surface, theme) ;
237
237
}
238
238
239
- let statusline_area = view
240
- . area
241
- . clip_top ( view. area . height . saturating_sub ( 1 ) )
242
- . clip_bottom ( config. commandline as u16 ) ; // -1 from bottom to remove commandline
239
+ if editor. status_msg . is_none ( ) {
240
+ let statusline_area = view
241
+ . area
242
+ . clip_top ( view. area . height . saturating_sub ( 1 ) )
243
+ . clip_bottom ( config. commandline as u16 ) ; // -1 from bottom to remove commandline
243
244
244
- let mut context =
245
- statusline:: RenderContext :: new ( editor, doc, view, is_focused, & self . spinners ) ;
245
+ let mut context =
246
+ statusline:: RenderContext :: new ( editor, doc, view, is_focused, & self . spinners ) ;
246
247
247
- statusline:: render ( & mut context, statusline_area, surface) ;
248
+ statusline:: render ( & mut context, statusline_area, surface) ;
249
+ }
248
250
}
249
251
250
252
pub fn render_rulers (
@@ -480,12 +482,35 @@ impl EditorView {
480
482
let cursorkind = cursor_shape_config. from_mode ( mode) ;
481
483
let cursor_is_block = cursorkind == CursorKind :: Block ;
482
484
483
- let selection_scope = theme
484
- . find_scope_index_exact ( "ui.selection" )
485
- . expect ( "could not find `ui.selection` scope in the theme!" ) ;
486
- let primary_selection_scope = theme
487
- . find_scope_index_exact ( "ui.selection.primary" )
488
- . unwrap_or ( selection_scope) ;
485
+ // let selection_scope = theme
486
+ // .find_scope_index_exact("ui.selection")
487
+ // .expect("could not find `ui.selection` scope in the theme!");
488
+
489
+ let selection_scope = match mode {
490
+ Mode :: Normal => theme. find_scope_index_exact ( "ui.selection.normal" ) ,
491
+ Mode :: Select => theme. find_scope_index_exact ( "ui.selection.select" ) ,
492
+ Mode :: Insert => theme. find_scope_index_exact ( "ui.selection.insert" ) ,
493
+ }
494
+ . unwrap_or (
495
+ theme
496
+ . find_scope_index_exact ( "ui.selection" )
497
+ . expect ( "could not find `ui.selection` scope in the theme!" ) ,
498
+ ) ;
499
+
500
+ // let primary_selection_scope = theme
501
+ // .find_scope_index_exact("ui.selection.primary")
502
+ // .unwrap_or(selection_scope);
503
+
504
+ let primary_selection_scope = match mode {
505
+ Mode :: Normal => theme. find_scope_index_exact ( "ui.selection.primary.normal" ) ,
506
+ Mode :: Select => theme. find_scope_index_exact ( "ui.selection.primary.select" ) ,
507
+ Mode :: Insert => theme. find_scope_index_exact ( "ui.selection.primary.insert" ) ,
508
+ }
509
+ . unwrap_or (
510
+ theme
511
+ . find_scope_index_exact ( "ui.selection.primary" )
512
+ . expect ( "could not find `ui.selection.primary` scope in the theme!" ) ,
513
+ ) ;
489
514
490
515
let base_cursor_scope = theme
491
516
. find_scope_index_exact ( "ui.cursor" )
@@ -795,7 +820,7 @@ impl EditorView {
795
820
}
796
821
797
822
/// Apply the highlighting on the lines where a cursor is active
798
- pub fn cursorline ( doc : & Document , view : & View , theme : & Theme ) -> impl Decoration {
823
+ pub fn cursorline ( doc : & Document , view : & View , theme : & Theme , mode : & Mode ) -> impl Decoration {
799
824
let text = doc. text ( ) . slice ( ..) ;
800
825
// TODO only highlight the visual line that contains the cursor instead of the full visual line
801
826
let primary_line = doc. selection ( view. id ) . primary ( ) . cursor_line ( text) ;
@@ -812,7 +837,13 @@ impl EditorView {
812
837
. map ( |range| range. cursor_line ( text) )
813
838
. collect ( ) ;
814
839
815
- let primary_style = theme. get ( "ui.cursorline.primary" ) ;
840
+ let primary_style = match mode {
841
+ Mode :: Normal => theme. try_get ( "ui.cursorline.primary.normal" ) ,
842
+ Mode :: Select => theme. try_get ( "ui.cursorline.primary.select" ) ,
843
+ Mode :: Insert => theme. try_get ( "ui.cursorline.primary.insert" ) ,
844
+ }
845
+ . unwrap_or ( theme. get ( "ui.cursorline.primary" ) ) ;
846
+
816
847
let secondary_style = theme. get ( "ui.cursorline.secondary" ) ;
817
848
let viewport = view. area ;
818
849
@@ -1581,7 +1612,7 @@ impl Component for EditorView {
1581
1612
let mut status_msg_width = 0 ;
1582
1613
1583
1614
// commandline
1584
- let commandline_msg_pos = if config. commandline { 1 } else { 2 } ;
1615
+ let commandline_msg_pos = 1 ; // if config.commandline { 1 } else { 1 };
1585
1616
1586
1617
// render status msg
1587
1618
if let Some ( ( status_msg, severity) ) = & cx. editor . status_msg {
@@ -1620,7 +1651,11 @@ impl Component for EditorView {
1620
1651
} ;
1621
1652
surface. set_string (
1622
1653
area. x + area. width . saturating_sub ( key_width + macro_width) ,
1623
- area. y + area. height . saturating_sub ( commandline_msg_pos) ,
1654
+ area. y
1655
+ + area
1656
+ . height
1657
+ . saturating_sub ( commandline_msg_pos)
1658
+ . saturating_sub ( 1 ) ,
1624
1659
disp. get ( disp. len ( ) . saturating_sub ( key_width as usize ) ..)
1625
1660
. unwrap_or ( & disp) ,
1626
1661
style,
0 commit comments