diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-12-05 16:08:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-05 16:08:36 +0100 |
| commit | a260acc668f45ec266730ee28d55bbfd071de236 (patch) | |
| tree | 67f18b9456ddf9f2866a2290ce7274a74180f57a | |
| parent | 81b6263dd03aa9288a03178a4ec556922d5332c4 (diff) | |
| parent | 15a8e9d59b2967f9f7baea85d1463b20e3b0d970 (diff) | |
| download | rust-a260acc668f45ec266730ee28d55bbfd071de236.tar.gz rust-a260acc668f45ec266730ee28d55bbfd071de236.zip | |
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.
| -rw-r--r-- | src/bootstrap/src/core/build_steps/setup.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index 49373177abe..fe84b95f90c 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -549,12 +549,13 @@ impl Step for Vscode { if config.dry_run() { return; } - t!(create_vscode_settings_maybe(&config)); + while !t!(create_vscode_settings_maybe(&config)) {} } } /// Create a `.vscode/settings.json` file for rustc development, or just print it -fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> { +/// If this method should be re-called, it returns `false`. +fn create_vscode_settings_maybe(config: &Config) -> io::Result<bool> { let (current_hash, historical_hashes) = SETTINGS_HASHES.split_last().unwrap(); let vscode_settings = config.src.join(".vscode").join("settings.json"); // If None, no settings.json exists @@ -567,7 +568,7 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> { hasher.update(¤t); let hash = hex::encode(hasher.finalize().as_slice()); if hash == *current_hash { - return Ok(()); + return Ok(true); } else if historical_hashes.contains(&hash.as_str()) { mismatched_settings = Some(true); } else { @@ -587,13 +588,13 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> { _ => (), } let should_create = match prompt_user( - "Would you like to create/update `settings.json`, or only print suggested settings?: [y/p/N]", + "Would you like to create/update settings.json? (Press 'p' to preview values): [y/N]", )? { Some(PromptResult::Yes) => true, Some(PromptResult::Print) => false, _ => { println!("Ok, skipping settings!"); - return Ok(()); + return Ok(true); } }; if should_create { @@ -620,5 +621,5 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> { } else { println!("\n{RUST_ANALYZER_SETTINGS}"); } - Ok(()) + Ok(should_create) } |
