@@ -80,6 +80,7 @@ fn exit(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> anyhow:
8080 WriteOptions {
8181 force : false ,
8282 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
83+ code_actions : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
8384 } ,
8485 ) ?;
8586 }
@@ -99,6 +100,7 @@ fn force_exit(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> a
99100 WriteOptions {
100101 force : true ,
101102 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
103+ code_actions : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
102104 } ,
103105 ) ?;
104106 }
@@ -398,7 +400,9 @@ fn write_impl(
398400 // Save an undo checkpoint for any outstanding changes.
399401 doc. append_changes_to_history ( view) ;
400402
401- code_actions_on_save ( cx, & doc_id) ;
403+ if options. code_actions {
404+ code_actions_on_save ( cx, & doc_id) ;
405+ }
402406
403407 let ( view, doc) = current_ref ! ( cx. editor) ;
404408 let fmt = if config. auto_format && options. auto_format {
@@ -489,6 +493,7 @@ fn insert_final_newline(doc: &mut Document, view_id: ViewId) {
489493pub struct WriteOptions {
490494 pub force : bool ,
491495 pub auto_format : bool ,
496+ pub code_actions : bool ,
492497}
493498
494499fn write ( cx : & mut compositor:: Context , args : Args , event : PromptEvent ) -> anyhow:: Result < ( ) > {
@@ -502,6 +507,7 @@ fn write(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> anyhow
502507 WriteOptions {
503508 force : false ,
504509 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
510+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
505511 } ,
506512 )
507513}
@@ -517,6 +523,7 @@ fn force_write(cx: &mut compositor::Context, args: Args, event: PromptEvent) ->
517523 WriteOptions {
518524 force : true ,
519525 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
526+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
520527 } ,
521528 )
522529}
@@ -536,6 +543,7 @@ fn write_buffer_close(
536543 WriteOptions {
537544 force : false ,
538545 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
546+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
539547 } ,
540548 ) ?;
541549
@@ -558,6 +566,7 @@ fn force_write_buffer_close(
558566 WriteOptions {
559567 force : true ,
560568 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
569+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
561570 } ,
562571 ) ?;
563572
@@ -746,6 +755,7 @@ fn write_quit(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> a
746755 WriteOptions {
747756 force : false ,
748757 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
758+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
749759 } ,
750760 ) ?;
751761 cx. block_try_flush_writes ( ) ?;
@@ -767,6 +777,7 @@ fn force_write_quit(
767777 WriteOptions {
768778 force : true ,
769779 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
780+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
770781 } ,
771782 ) ?;
772783 cx. block_try_flush_writes ( ) ?;
@@ -811,6 +822,7 @@ pub struct WriteAllOptions {
811822 pub force : bool ,
812823 pub write_scratch : bool ,
813824 pub auto_format : bool ,
825+ pub code_actions : bool ,
814826}
815827
816828pub fn write_all_impl (
@@ -861,7 +873,9 @@ pub fn write_all_impl(
861873 // Save an undo checkpoint for any outstanding changes.
862874 doc. append_changes_to_history ( view) ;
863875
864- code_actions_on_save ( cx, & doc_id) ;
876+ if options. code_actions {
877+ code_actions_on_save ( cx, & doc_id) ;
878+ }
865879
866880 let fmt = if options. auto_format && config. auto_format {
867881 let doc = doc ! ( cx. editor, & doc_id) ;
@@ -903,6 +917,7 @@ fn write_all(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> an
903917 force : false ,
904918 write_scratch : true ,
905919 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
920+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
906921 } ,
907922 )
908923}
@@ -922,6 +937,7 @@ fn force_write_all(
922937 force : true ,
923938 write_scratch : true ,
924939 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
940+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
925941 } ,
926942 )
927943}
@@ -940,6 +956,7 @@ fn write_all_quit(
940956 force : false ,
941957 write_scratch : true ,
942958 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
959+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
943960 } ,
944961 ) ?;
945962 quit_all_impl ( cx, false )
@@ -959,6 +976,7 @@ fn force_write_all_quit(
959976 force : true ,
960977 write_scratch : true ,
961978 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
979+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
962980 } ,
963981 ) ;
964982 quit_all_impl ( cx, true )
@@ -1522,6 +1540,7 @@ fn update(cx: &mut compositor::Context, args: Args, event: PromptEvent) -> anyho
15221540 WriteOptions {
15231541 force : false ,
15241542 auto_format : !args. has_flag ( WRITE_NO_FORMAT_FLAG . name ) ,
1543+ code_actions : !args. has_flag ( WRITE_NO_CODE_ACTIONS_FLAG . name ) ,
15251544 } ,
15261545 )
15271546 } else {
@@ -2719,6 +2738,12 @@ const WRITE_NO_FORMAT_FLAG: Flag = Flag {
27192738 ..Flag :: DEFAULT
27202739} ;
27212740
2741+ const WRITE_NO_CODE_ACTIONS_FLAG : Flag = Flag {
2742+ name : "no-code-actions" ,
2743+ doc : "skip code actions on save" ,
2744+ ..Flag :: DEFAULT
2745+ } ;
2746+
27222747pub const TYPABLE_COMMAND_LIST : & [ TypableCommand ] = & [
27232748 TypableCommand {
27242749 name : "exit" ,
@@ -2867,7 +2892,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
28672892 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
28682893 signature : Signature {
28692894 positionals : ( 0 , Some ( 1 ) ) ,
2870- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2895+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
28712896 ..Signature :: DEFAULT
28722897 } ,
28732898 } ,
@@ -2879,7 +2904,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
28792904 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
28802905 signature : Signature {
28812906 positionals : ( 0 , Some ( 1 ) ) ,
2882- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2907+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
28832908 ..Signature :: DEFAULT
28842909 } ,
28852910 } ,
@@ -2891,7 +2916,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
28912916 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
28922917 signature : Signature {
28932918 positionals : ( 0 , Some ( 1 ) ) ,
2894- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2919+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
28952920 ..Signature :: DEFAULT
28962921 } ,
28972922 } ,
@@ -2903,7 +2928,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
29032928 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
29042929 signature : Signature {
29052930 positionals : ( 0 , Some ( 1 ) ) ,
2906- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2931+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
29072932 ..Signature :: DEFAULT
29082933 } ,
29092934 } ,
@@ -2984,7 +3009,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
29843009 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
29853010 signature : Signature {
29863011 positionals : ( 0 , Some ( 1 ) ) ,
2987- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3012+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
29883013 ..Signature :: DEFAULT
29893014 } ,
29903015 } ,
@@ -2996,7 +3021,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
29963021 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
29973022 signature : Signature {
29983023 positionals : ( 0 , Some ( 1 ) ) ,
2999- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3024+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30003025 ..Signature :: DEFAULT
30013026 } ,
30023027 } ,
@@ -3008,7 +3033,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
30083033 completer : CommandCompleter :: none ( ) ,
30093034 signature : Signature {
30103035 positionals : ( 0 , Some ( 0 ) ) ,
3011- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3036+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30123037 ..Signature :: DEFAULT
30133038 } ,
30143039 } ,
@@ -3020,7 +3045,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
30203045 completer : CommandCompleter :: none ( ) ,
30213046 signature : Signature {
30223047 positionals : ( 0 , Some ( 0 ) ) ,
3023- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3048+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30243049 ..Signature :: DEFAULT
30253050 } ,
30263051 } ,
@@ -3032,7 +3057,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
30323057 completer : CommandCompleter :: none ( ) ,
30333058 signature : Signature {
30343059 positionals : ( 0 , Some ( 0 ) ) ,
3035- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3060+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30363061 ..Signature :: DEFAULT
30373062 } ,
30383063 } ,
@@ -3044,7 +3069,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
30443069 completer : CommandCompleter :: none ( ) ,
30453070 signature : Signature {
30463071 positionals : ( 0 , Some ( 0 ) ) ,
3047- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3072+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30483073 ..Signature :: DEFAULT
30493074 } ,
30503075 } ,
@@ -3309,7 +3334,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
33093334 completer : CommandCompleter :: none ( ) ,
33103335 signature : Signature {
33113336 positionals : ( 0 , Some ( 0 ) ) ,
3312- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3337+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
33133338 ..Signature :: DEFAULT
33143339 } ,
33153340 } ,
0 commit comments