@@ -360,7 +360,9 @@ fn write_impl(
360
360
// Save an undo checkpoint for any outstanding changes.
361
361
doc. append_changes_to_history ( view) ;
362
362
363
- code_actions_on_save ( cx, & doc_id) ;
363
+ if options. code_actions {
364
+ code_actions_on_save ( cx, & doc_id) ;
365
+ }
364
366
365
367
let ( view, doc) = current_ref ! ( cx. editor) ;
366
368
let fmt = if config. auto_format && options. auto_format {
@@ -451,6 +453,7 @@ fn insert_final_newline(doc: &mut Document, view_id: ViewId) {
451
453
pub struct WriteOptions {
452
454
pub force : bool ,
453
455
pub auto_format : bool ,
456
+ pub code_actions : bool ,
454
457
}
455
458
456
459
fn write ( cx : & mut compositor:: Context , args : Args , event : PromptEvent ) -> anyhow:: Result < ( ) > {
@@ -464,6 +467,7 @@ fn write(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> anyhow
464
467
WriteOptions {
465
468
force : false ,
466
469
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
470
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
467
471
} ,
468
472
)
469
473
}
@@ -479,6 +483,7 @@ fn force_write(cx: &mut compositor::Context, args: Args, event: PromptEvent) ->
479
483
WriteOptions {
480
484
force : true ,
481
485
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
486
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
482
487
} ,
483
488
)
484
489
}
@@ -498,6 +503,7 @@ fn write_buffer_close(
498
503
WriteOptions {
499
504
force : false ,
500
505
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
506
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
501
507
} ,
502
508
) ?;
503
509
@@ -520,6 +526,7 @@ fn force_write_buffer_close(
520
526
WriteOptions {
521
527
force : true ,
522
528
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
529
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
523
530
} ,
524
531
) ?;
525
532
@@ -708,6 +715,7 @@ fn write_quit(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> a
708
715
WriteOptions {
709
716
force : false ,
710
717
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
718
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
711
719
} ,
712
720
) ?;
713
721
cx. block_try_flush_writes ( ) ?;
@@ -729,6 +737,7 @@ fn force_write_quit(
729
737
WriteOptions {
730
738
force : true ,
731
739
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
740
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
732
741
} ,
733
742
) ?;
734
743
cx. block_try_flush_writes ( ) ?;
@@ -773,6 +782,7 @@ pub struct WriteAllOptions {
773
782
pub force : bool ,
774
783
pub write_scratch : bool ,
775
784
pub auto_format : bool ,
785
+ pub code_actions : bool ,
776
786
}
777
787
778
788
pub fn write_all_impl (
@@ -823,7 +833,9 @@ pub fn write_all_impl(
823
833
// Save an undo checkpoint for any outstanding changes.
824
834
doc. append_changes_to_history ( view) ;
825
835
826
- code_actions_on_save ( cx, & doc_id) ;
836
+ if options. code_actions {
837
+ code_actions_on_save ( cx, & doc_id) ;
838
+ }
827
839
828
840
let fmt = if options. auto_format && config. auto_format {
829
841
let doc = doc ! ( cx. editor, & doc_id) ;
@@ -865,6 +877,7 @@ fn write_all(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> an
865
877
force : false ,
866
878
write_scratch : true ,
867
879
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
880
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
868
881
} ,
869
882
)
870
883
}
@@ -884,6 +897,7 @@ fn force_write_all(
884
897
force : true ,
885
898
write_scratch : true ,
886
899
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
900
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
887
901
} ,
888
902
)
889
903
}
@@ -902,6 +916,7 @@ fn write_all_quit(
902
916
force : false ,
903
917
write_scratch : true ,
904
918
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
919
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
905
920
} ,
906
921
) ?;
907
922
quit_all_impl ( cx, false )
@@ -921,6 +936,7 @@ fn force_write_all_quit(
921
936
force : true ,
922
937
write_scratch : true ,
923
938
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
939
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
924
940
} ,
925
941
) ;
926
942
quit_all_impl ( cx, true )
@@ -1484,6 +1500,7 @@ fn update(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> anyho
1484
1500
WriteOptions {
1485
1501
force : false ,
1486
1502
auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
1503
+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
1487
1504
} ,
1488
1505
)
1489
1506
} else {
@@ -2681,6 +2698,12 @@ const WRITE_NO_FORMAT_FLAG: Flag = Flag {
2681
2698
..Flag :: DEFAULT
2682
2699
} ;
2683
2700
2701
+ const WRITE_NO_CODE_ACTIONS_FLAG : Flag = Flag {
2702
+ name : "no-code-actions" ,
2703
+ doc : "skip code actions on save" ,
2704
+ ..Flag :: DEFAULT
2705
+ } ;
2706
+
2684
2707
pub const TYPABLE_COMMAND_LIST : & [ TypableCommand ] = & [
2685
2708
TypableCommand {
2686
2709
name : "quit" ,
@@ -2805,7 +2828,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2805
2828
completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
2806
2829
signature : Signature {
2807
2830
positionals : ( 0 , Some ( 1 ) ) ,
2808
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2831
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
2809
2832
..Signature :: DEFAULT
2810
2833
} ,
2811
2834
} ,
@@ -2817,7 +2840,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2817
2840
completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
2818
2841
signature : Signature {
2819
2842
positionals : ( 0 , Some ( 1 ) ) ,
2820
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2843
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
2821
2844
..Signature :: DEFAULT
2822
2845
} ,
2823
2846
} ,
@@ -2829,7 +2852,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2829
2852
completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
2830
2853
signature : Signature {
2831
2854
positionals : ( 0 , Some ( 1 ) ) ,
2832
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2855
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
2833
2856
..Signature :: DEFAULT
2834
2857
} ,
2835
2858
} ,
@@ -2841,7 +2864,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2841
2864
completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
2842
2865
signature : Signature {
2843
2866
positionals : ( 0 , Some ( 1 ) ) ,
2844
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2867
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
2845
2868
..Signature :: DEFAULT
2846
2869
} ,
2847
2870
} ,
@@ -2922,7 +2945,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2922
2945
completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
2923
2946
signature : Signature {
2924
2947
positionals : ( 0 , Some ( 1 ) ) ,
2925
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2948
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
2926
2949
..Signature :: DEFAULT
2927
2950
} ,
2928
2951
} ,
@@ -2934,7 +2957,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2934
2957
completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
2935
2958
signature : Signature {
2936
2959
positionals : ( 0 , Some ( 1 ) ) ,
2937
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2960
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
2938
2961
..Signature :: DEFAULT
2939
2962
} ,
2940
2963
} ,
@@ -2946,7 +2969,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2946
2969
completer : CommandCompleter :: none ( ) ,
2947
2970
signature : Signature {
2948
2971
positionals : ( 0 , Some ( 0 ) ) ,
2949
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2972
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
2950
2973
..Signature :: DEFAULT
2951
2974
} ,
2952
2975
} ,
@@ -2958,7 +2981,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2958
2981
completer : CommandCompleter :: none ( ) ,
2959
2982
signature : Signature {
2960
2983
positionals : ( 0 , Some ( 0 ) ) ,
2961
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2984
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
2962
2985
..Signature :: DEFAULT
2963
2986
} ,
2964
2987
} ,
@@ -2970,7 +2993,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2970
2993
completer : CommandCompleter :: none ( ) ,
2971
2994
signature : Signature {
2972
2995
positionals : ( 0 , Some ( 0 ) ) ,
2973
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2996
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
2974
2997
..Signature :: DEFAULT
2975
2998
} ,
2976
2999
} ,
@@ -2982,7 +3005,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2982
3005
completer : CommandCompleter :: none ( ) ,
2983
3006
signature : Signature {
2984
3007
positionals : ( 0 , Some ( 0 ) ) ,
2985
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3008
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
2986
3009
..Signature :: DEFAULT
2987
3010
} ,
2988
3011
} ,
@@ -3247,7 +3270,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
3247
3270
completer : CommandCompleter :: none ( ) ,
3248
3271
signature : Signature {
3249
3272
positionals : ( 0 , Some ( 0 ) ) ,
3250
- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3273
+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
3251
3274
..Signature :: DEFAULT
3252
3275
} ,
3253
3276
} ,
0 commit comments