Skip to content

Commit a260acc

Browse files
authoredDec 5, 2023
Rollup merge of #118606 - long-long-float:x-do-not-quit-when-x-prints-settings-json, r=onur-ozkan
Fix `x` not to quit after `x` prints `settings.json` I fixed the `x` not to quit after the `x` prints `.vscode/settings.json`. The command `x setup` ask as following: ``` x.py can automatically install the recommended `.vscode/settings.json` file for rustc development Would you like to create/update `settings.json`, or only print suggested settings?: [y/p/N] ``` When user types `p`, the `x` prints the contents and quit the program. It is a hassle to start the command again, so I fixed the `x` to ask what to do again.
2 parents 81b6263 + 15a8e9d commit a260acc

File tree

1 file changed

+7
-6
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+7
-6
lines changed
 

‎src/bootstrap/src/core/build_steps/setup.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,13 @@ impl Step for Vscode {
549549
if config.dry_run() {
550550
return;
551551
}
552-
t!(create_vscode_settings_maybe(&config));
552+
while !t!(create_vscode_settings_maybe(&config)) {}
553553
}
554554
}
555555

556556
/// Create a `.vscode/settings.json` file for rustc development, or just print it
557-
fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
557+
/// If this method should be re-called, it returns `false`.
558+
fn create_vscode_settings_maybe(config: &Config) -> io::Result<bool> {
558559
let (current_hash, historical_hashes) = SETTINGS_HASHES.split_last().unwrap();
559560
let vscode_settings = config.src.join(".vscode").join("settings.json");
560561
// If None, no settings.json exists
@@ -567,7 +568,7 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
567568
hasher.update(&current);
568569
let hash = hex::encode(hasher.finalize().as_slice());
569570
if hash == *current_hash {
570-
return Ok(());
571+
return Ok(true);
571572
} else if historical_hashes.contains(&hash.as_str()) {
572573
mismatched_settings = Some(true);
573574
} else {
@@ -587,13 +588,13 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
587588
_ => (),
588589
}
589590
let should_create = match prompt_user(
590-
"Would you like to create/update `settings.json`, or only print suggested settings?: [y/p/N]",
591+
"Would you like to create/update settings.json? (Press 'p' to preview values): [y/N]",
591592
)? {
592593
Some(PromptResult::Yes) => true,
593594
Some(PromptResult::Print) => false,
594595
_ => {
595596
println!("Ok, skipping settings!");
596-
return Ok(());
597+
return Ok(true);
597598
}
598599
};
599600
if should_create {
@@ -620,5 +621,5 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
620621
} else {
621622
println!("\n{RUST_ANALYZER_SETTINGS}");
622623
}
623-
Ok(())
624+
Ok(should_create)
624625
}

0 commit comments

Comments
 (0)