@@ -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 {
@@ -2769,6 +2788,12 @@ const WRITE_NO_FORMAT_FLAG: Flag = Flag {
27692788 ..Flag :: DEFAULT
27702789} ;
27712790
2791+ const WRITE_NO_CODE_ACTIONS_FLAG : Flag = Flag {
2792+ name : "no-code-actions" ,
2793+ doc : "skip code actions on save" ,
2794+ ..Flag :: DEFAULT
2795+ } ;
2796+
27722797pub const TYPABLE_COMMAND_LIST : & [ TypableCommand ] = & [
27732798 TypableCommand {
27742799 name : "exit" ,
@@ -2917,7 +2942,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
29172942 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
29182943 signature : Signature {
29192944 positionals : ( 0 , Some ( 1 ) ) ,
2920- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2945+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
29212946 ..Signature :: DEFAULT
29222947 } ,
29232948 } ,
@@ -2929,7 +2954,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
29292954 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
29302955 signature : Signature {
29312956 positionals : ( 0 , Some ( 1 ) ) ,
2932- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2957+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
29332958 ..Signature :: DEFAULT
29342959 } ,
29352960 } ,
@@ -2941,7 +2966,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
29412966 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
29422967 signature : Signature {
29432968 positionals : ( 0 , Some ( 1 ) ) ,
2944- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2969+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
29452970 ..Signature :: DEFAULT
29462971 } ,
29472972 } ,
@@ -2953,7 +2978,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
29532978 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
29542979 signature : Signature {
29552980 positionals : ( 0 , Some ( 1 ) ) ,
2956- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
2981+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
29572982 ..Signature :: DEFAULT
29582983 } ,
29592984 } ,
@@ -3034,7 +3059,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
30343059 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
30353060 signature : Signature {
30363061 positionals : ( 0 , Some ( 1 ) ) ,
3037- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3062+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30383063 ..Signature :: DEFAULT
30393064 } ,
30403065 } ,
@@ -3046,7 +3071,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
30463071 completer : CommandCompleter :: positional ( & [ completers:: filename] ) ,
30473072 signature : Signature {
30483073 positionals : ( 0 , Some ( 1 ) ) ,
3049- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3074+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30503075 ..Signature :: DEFAULT
30513076 } ,
30523077 } ,
@@ -3058,7 +3083,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
30583083 completer : CommandCompleter :: none ( ) ,
30593084 signature : Signature {
30603085 positionals : ( 0 , Some ( 0 ) ) ,
3061- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3086+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30623087 ..Signature :: DEFAULT
30633088 } ,
30643089 } ,
@@ -3070,7 +3095,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
30703095 completer : CommandCompleter :: none ( ) ,
30713096 signature : Signature {
30723097 positionals : ( 0 , Some ( 0 ) ) ,
3073- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3098+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30743099 ..Signature :: DEFAULT
30753100 } ,
30763101 } ,
@@ -3082,7 +3107,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
30823107 completer : CommandCompleter :: none ( ) ,
30833108 signature : Signature {
30843109 positionals : ( 0 , Some ( 0 ) ) ,
3085- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3110+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30863111 ..Signature :: DEFAULT
30873112 } ,
30883113 } ,
@@ -3094,7 +3119,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
30943119 completer : CommandCompleter :: none ( ) ,
30953120 signature : Signature {
30963121 positionals : ( 0 , Some ( 0 ) ) ,
3097- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3122+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
30983123 ..Signature :: DEFAULT
30993124 } ,
31003125 } ,
@@ -3359,7 +3384,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
33593384 completer : CommandCompleter :: none ( ) ,
33603385 signature : Signature {
33613386 positionals : ( 0 , Some ( 0 ) ) ,
3362- flags : & [ WRITE_NO_FORMAT_FLAG ] ,
3387+ flags : & [ WRITE_NO_FORMAT_FLAG , WRITE_NO_CODE_ACTIONS_FLAG ] ,
33633388 ..Signature :: DEFAULT
33643389 } ,
33653390 } ,
0 commit comments