Skip to content

Commit

Permalink
Revert "don't save options automaticly, add new command to save options"
Browse files Browse the repository at this point in the history
This reverts commit 74f9251.
  • Loading branch information
sigmaSd committed Oct 6, 2024
1 parent 9210fb1 commit 8b4145e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
2 changes: 0 additions & 2 deletions crates/irust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ You can try out IRust with no installation or setup (via Gitpod.io) by visiting

**:exit** | **:quit** => Exit IRust immediately

**:save_options** => save the options to disk (useful when options where changed at runtime)

**$$** => Shell commands can be interpolated with rust code with '$$', for example: `let a = $$ls -l$$;`, this feature can be [en/dis]abled via the config file

**::** => run a shell command, example `::ls`
Expand Down
5 changes: 5 additions & 0 deletions crates/irust/src/irust/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub struct Engine {
macros: HashMap<char, Vec<Command>>,
buffers: Vec<Buffer>,
buffers_idx: usize,
// defaults to false
pub dont_save_options: bool,
}

impl IRust {
Expand Down Expand Up @@ -678,6 +680,9 @@ impl IRust {
// Give scripts a chance to clean-up
self.run_scripts_shutdown_cmds()?;
self.history.save()?;
if !self.engine.dont_save_options {
self.options.save()?;
}
self.printer.write_newline(&self.buffer);
self.printer.cursor.show();
Ok(())
Expand Down
3 changes: 3 additions & 0 deletions crates/irust/src/irust/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ impl IRust {
|| (shell_cmd && self.options.add_shell_cmd_to_history)
|| (!irust_cmd && !shell_cmd)
}
pub fn dont_save_options(&mut self) {
self.engine.dont_save_options = true;
}
}

#[allow(clippy::upper_case_acronyms)]
Expand Down
6 changes: 0 additions & 6 deletions crates/irust/src/irust/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ impl IRust {
":irust" => self.irust(),
":sync" => self.sync(),
":exit" | ":quit" => self.exit(),
":save_options" => self.save_options(),
cmd if cmd.starts_with(":help") => self.help(buffer),
cmd if cmd.starts_with("::") => self.run_cmd(buffer),
cmd if cmd.starts_with(":edit") => self.extern_edit(buffer),
Expand Down Expand Up @@ -1042,11 +1041,6 @@ impl IRust {
self.exit_flag = true;
Ok(PrintQueue::default())
}

fn save_options(&mut self) -> Result<PrintQueue> {
self.options.save()?;
success!()
}
}

// These patterns are used to detect statements that don't require to be terminated with ';'
Expand Down
3 changes: 1 addition & 2 deletions crates/irust/src/irust/ra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct Completer {
// suggestions: (Name, definition)
suggestions: Vec<(String, String)>,
suggestion_idx: usize,
cmds: [String; 31],
cmds: [String; 30],
update_lock: bool,
pub active_suggestion: Option<String>,
}
Expand Down Expand Up @@ -53,7 +53,6 @@ impl Completer {
"toolchain".to_string(),
"theme".to_string(),
"main_result".to_string(),
"save_options".to_string(),
"check_statements".to_string(),
"time_release".to_string(),
"time".to_string(),
Expand Down
4 changes: 3 additions & 1 deletion crates/irust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ fn main() {

// Create main IRust interface
let mut irust = if matches!(args_result, ArgsResult::ProceedWithDefaultConfig) {
IRust::new(Options::default())
let mut irust = IRust::new(Options::default());
irust.dont_save_options();
irust
} else {
// Check optional dependencies and warn if they're not present
if !cfg!(feature = "no-welcome-screen") {
Expand Down

0 comments on commit 8b4145e

Please sign in to comment.