File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -4875,7 +4875,16 @@ fn indent(cx: &mut Context) {
4875
4875
return None ;
4876
4876
}
4877
4877
let pos = doc. text ( ) . line_to_char ( line) ;
4878
- Some ( ( pos, pos, Some ( indent. clone ( ) ) ) )
4878
+
4879
+ let indent = if let IndentStyle :: Spaces ( indent_width) = doc. indent_style {
4880
+ let line = doc. text ( ) . line ( line) ;
4881
+ let offset = line. first_non_whitespace_char ( ) . unwrap_or ( 0 ) % indent_width as usize ;
4882
+ indent. clone ( ) . split_off ( offset)
4883
+ } else {
4884
+ indent. clone ( )
4885
+ } ;
4886
+
4887
+ Some ( ( pos, pos, Some ( indent) ) )
4879
4888
} ) ,
4880
4889
) ;
4881
4890
doc. apply ( & transaction, view. id ) ;
Original file line number Diff line number Diff line change @@ -585,7 +585,7 @@ async fn test_jump_undo_redo() -> anyhow::Result<()> {
585
585
}
586
586
587
587
#[ tokio:: test( flavor = "multi_thread" ) ]
588
- async fn test_spaces_alignment_on_insert_tab ( ) -> anyhow:: Result < ( ) > {
588
+ async fn test_indent_with_spaces ( ) -> anyhow:: Result < ( ) > {
589
589
let tests = vec ! [
590
590
// at start of line
591
591
(
@@ -615,6 +615,22 @@ async fn test_spaces_alignment_on_insert_tab() -> anyhow::Result<()> {
615
615
WHERE #(|condition)#
616
616
" } ,
617
617
) ,
618
+ // indentation in normal mode
619
+ (
620
+ indoc! { "\
621
+ -- comment
622
+ #[|SELECT *
623
+ FROM table
624
+ WHERE condition]#
625
+ " } ,
626
+ "<gt>" ,
627
+ indoc! { "\
628
+ -- comment
629
+ #[|SELECT *
630
+ FROM table
631
+ WHERE condition]#
632
+ " } ,
633
+ ) ,
618
634
] ;
619
635
620
636
for test in tests {
You can’t perform that action at this time.
0 commit comments