Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not log the last mode on stack if @entering an invalid mode #259

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions swhkd/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,19 +509,15 @@ pub fn send_command(
if command.contains('@') {
let commands = command.split("&&").map(|s| s.trim()).collect::<Vec<_>>();
for cmd in commands {
let mut words = cmd.split_whitespace();
match words.next().unwrap() {
config::MODE_ENTER_STATEMENT => {
let enter_mode = cmd.split(' ').nth(1).unwrap();
for (i, mode) in modes.iter().enumerate() {
if mode.name == enter_mode {
mode_stack.push(i);
break;
}
let words: Vec<_> = cmd.split_whitespace().collect();
match &words[..] {
&[config::MODE_ENTER_STATEMENT, enter_mode, ..] => {
if let Some(i) = modes.iter().position(|mode| mode.name == enter_mode) {
mode_stack.push(i);
log::info!("Entering mode: {}", enter_mode);
}
log::info!("Entering mode: {}", modes[mode_stack[mode_stack.len() - 1]].name);
}
config::MODE_ESCAPE_STATEMENT => {
&[config::MODE_ESCAPE_STATEMENT, ..] => {
mode_stack.pop();
}
_ => commands_to_send.push_str(format!("{cmd} &&").as_str()),
Expand Down
Loading