Skip to content

Commit

Permalink
add fixes I forgot to commit
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorrFG committed Nov 19, 2023
1 parent d61c144 commit 513fa04
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::process::Stdio;
use std::{fs, io};

use crate::outproxy::OutProxy;
use crate::parser::{self, CommandSetting, Menu, Node, ShellDef, SnippetTable};
use crate::parser::{self, CommandSetting, Menu, Node, SnippetTable};
use crate::rt_conf;

#[derive(Debug, Clone)]
Expand Down
25 changes: 17 additions & 8 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub enum StringExprElem {
String(String),
}

#[derive(Debug, Clone, Default)]
#[derive(Debug, Clone)]
pub struct Settings {
pub shell_def: Option<ShellDef>,
pub echo_by_default: bool,
Expand Down Expand Up @@ -101,6 +101,15 @@ impl INext for Pair<'_, Rule> {
}
}

impl Default for Settings {
fn default() -> Self {
Settings {
shell_def: None,
echo_by_default: true,
}
}
}

fn from_string(p: Pair<'_, Rule>) -> String {
p.nnext(2).as_str().to_string()
}
Expand All @@ -123,7 +132,7 @@ pub fn parse(src: &str) -> Result<Config> {
})
}

fn parse_settings<'a>(mut entries: Pairs<'a, Rule>) -> (Settings, Pairs<'a, Rule>) {
fn parse_settings(mut entries: Pairs<Rule>) -> (Settings, Pairs<Rule>) {
let mut res = Settings::default();
debug!("Parsing settings: \n{entries:?}");
while let Some(first_entry) = entries.peek() {
Expand Down Expand Up @@ -622,7 +631,7 @@ Config {
},
settings: Settings {
shell_def: None,
echo_by_default: false,
echo_by_default: true,
},
snippet_table: {},
}
Expand Down Expand Up @@ -696,7 +705,7 @@ Ok(
},
settings: Settings {
shell_def: None,
echo_by_default: false,
echo_by_default: true,
},
snippet_table: {},
},
Expand Down Expand Up @@ -748,7 +757,7 @@ Config {
},
settings: Settings {
shell_def: None,
echo_by_default: false,
echo_by_default: true,
},
snippet_table: {},
}
Expand Down Expand Up @@ -802,7 +811,7 @@ Config {
},
settings: Settings {
shell_def: None,
echo_by_default: false,
echo_by_default: true,
},
snippet_table: {},
}
Expand Down Expand Up @@ -846,7 +855,7 @@ Config {
},
settings: Settings {
shell_def: None,
echo_by_default: false,
echo_by_default: true,
},
snippet_table: {},
}
Expand Down Expand Up @@ -891,7 +900,7 @@ Config {
},
settings: Settings {
shell_def: None,
echo_by_default: false,
echo_by_default: true,
},
snippet_table: {},
}
Expand Down
12 changes: 8 additions & 4 deletions tests/bash_tests/arg_test.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[?25l[?25halpha beta gamma
[?25l[?25halpha beta lala
[?25l[?25halpha beta foo
[?25l[?25hfoo
[?25l[?25hecho $a $b $c
alpha beta gamma
[?25l[?25hecho $a $b $c
alpha beta lala
[?25l[?25hecho $a $b $c
alpha beta foo
[?25l[?25hecho $a $b $c
foo
Expand Down
2 changes: 0 additions & 2 deletions tests/bash_tests/echo_setting_on.dt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
echo on

menu root {
y: "echo show me"
n: @"echo don\'t show me"
Expand Down
2 changes: 2 additions & 0 deletions tests/bash_tests/string_test.dt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
echo off

snippet vars = !"
FOO="foo"
"!
Expand Down

0 comments on commit 513fa04

Please sign in to comment.