File tree Expand file tree Collapse file tree 5 files changed +19
-5
lines changed Expand file tree Collapse file tree 5 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ config_data! {
105
105
/// ```
106
106
/// .
107
107
cargo_buildScripts_overrideCommand: Option <Vec <String >> = "null" ,
108
- /// rerun proc-macros building/build-scripts running when proc-macro
108
+ /// Rerun proc-macros building/build-scripts running when proc-macro
109
109
/// or build-script sources change and are saved.
110
110
cargo_buildScripts_rebuildOnSave: bool = "false" ,
111
111
/// Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to
Original file line number Diff line number Diff line change @@ -351,10 +351,6 @@ impl GlobalState {
351
351
352
352
crates. iter ( ) . any ( |& krate| crate_graph[ krate] . is_proc_macro )
353
353
} ) ;
354
- if self . proc_macro_changed && self . config . script_rebuild_on_save ( ) {
355
- self . fetch_build_data_queue
356
- . request_op ( format ! ( "proc-macro or build script source changed" ) , ( ) )
357
- }
358
354
}
359
355
360
356
true
Original file line number Diff line number Diff line change @@ -130,6 +130,13 @@ pub(crate) fn handle_did_save_text_document(
130
130
state : & mut GlobalState ,
131
131
params : DidSaveTextDocumentParams ,
132
132
) -> anyhow:: Result < ( ) > {
133
+ if state. config . script_rebuild_on_save ( ) && state. proc_macro_changed {
134
+ // reset the flag
135
+ state. proc_macro_changed = false ;
136
+ // rebuild the proc macros
137
+ state. fetch_build_data_queue . request_op ( format ! ( "ScriptRebuildOnSave" ) , ( ) ) ;
138
+ }
139
+
133
140
if let Ok ( vfs_path) = from_proto:: vfs_path ( & params. text_document . uri ) {
134
141
// Re-fetch workspaces if a workspace related file has changed
135
142
if let Some ( abs_path) = vfs_path. as_path ( ) {
Original file line number Diff line number Diff line change @@ -71,6 +71,12 @@ cargo check --quiet --workspace --message-format=json --all-targets
71
71
```
72
72
.
73
73
--
74
+ [[rust-analyzer.cargo.buildScripts.rebuildOnSave]]rust-analyzer.cargo.buildScripts.rebuildOnSave (default: `false` )::
75
+ +
76
+ --
77
+ Rerun proc-macros building/build-scripts running when proc-macro
78
+ or build-script sources change and are saved.
79
+ --
74
80
[[rust-analyzer.cargo.buildScripts.useRustcWrapper]]rust-analyzer.cargo.buildScripts.useRustcWrapper (default: `true` )::
75
81
+
76
82
--
Original file line number Diff line number Diff line change 586
586
"type" : " string"
587
587
}
588
588
},
589
+ "rust-analyzer.cargo.buildScripts.rebuildOnSave" : {
590
+ "markdownDescription" : " Rerun proc-macros building/build-scripts running when proc-macro\n or build-script sources change and are saved." ,
591
+ "default" : false ,
592
+ "type" : " boolean"
593
+ },
589
594
"rust-analyzer.cargo.buildScripts.useRustcWrapper" : {
590
595
"markdownDescription" : " Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to\n avoid checking unnecessary things." ,
591
596
"default" : true ,
You can’t perform that action at this time.
0 commit comments