Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions docs/configuration/keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ uda.taskwarrior-tui.keyconfig.zoom=z
uda.taskwarrior-tui.keyconfig.context-menu=c
uda.taskwarrior-tui.keyconfig.next-tab=]
uda.taskwarrior-tui.keyconfig.previous-tab=[
uda.taskwarrior-tui.keyconfig.help=?
uda.taskwarrior-tui.keyconfig.priority-h=H
uda.taskwarrior-tui.keyconfig.priority-m=M
uda.taskwarrior-tui.keyconfig.priority-l=L
uda.taskwarrior-tui.keyconfig.priority-n=N
```
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4747,7 +4747,7 @@ mod tests {
"│ │",
"│ [: Previous view │",
"╰──────────────────────────────────────╯",
" 8% ───────────────────────────────────",
" 7% ───────────────────────────────────",
]);

for i in 1..=4 {
Expand Down
4 changes: 4 additions & 0 deletions src/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ fn keycode_for(name: &str, kc: &KeyConfig) -> KeyCode {
"shortcut8" => kc.shortcut8,
"context_menu" => kc.context_menu,
"help" => kc.help,
"priority_h" => kc.priority_h,
"priority_m" => kc.priority_m,
"priority_l" => kc.priority_l,
"priority_n" => kc.priority_n,
_ => KeyCode::Null,
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/help.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ Keybindings for task report:

{{annotate}}: task {selected} annotate {string} - Annotate current task

{{priority_h}}: priority H - Set priority to High

{{priority_m}}: priority M - Set priority to Medium

{{priority_l}}: priority L - Set priority to Low

{{priority_n}}: priority N - Remove priority

Ctrl-e: scroll down task details - Scroll task details view down one line

Ctrl-y: scroll up task details - Scroll task details view up one line
Expand Down
57 changes: 57 additions & 0 deletions src/keyconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ impl KeyConfig {
let shortcut7 = Self::get_config("uda.taskwarrior-tui.keyconfig.shortcut7", data);
let shortcut8 = Self::get_config("uda.taskwarrior-tui.keyconfig.shortcut8", data);
let shortcut9 = Self::get_config("uda.taskwarrior-tui.keyconfig.shortcut9", data);
let help = Self::get_config("uda.taskwarrior-tui.keyconfig.help", data);
let priority_h = Self::get_config("uda.taskwarrior-tui.keyconfig.priority-h", data);
let priority_m = Self::get_config("uda.taskwarrior-tui.keyconfig.priority-m", data);
let priority_l = Self::get_config("uda.taskwarrior-tui.keyconfig.priority-l", data);
let priority_n = Self::get_config("uda.taskwarrior-tui.keyconfig.priority-n", data);
Comment thread
cavanaug marked this conversation as resolved.

self.quit = quit.unwrap_or(self.quit);
self.refresh = refresh.unwrap_or(self.refresh);
Expand Down Expand Up @@ -184,6 +189,11 @@ impl KeyConfig {
self.shortcut7 = shortcut7.unwrap_or(self.shortcut7);
self.shortcut8 = shortcut8.unwrap_or(self.shortcut8);
self.shortcut9 = shortcut9.unwrap_or(self.shortcut9);
self.help = help.unwrap_or(self.help);
self.priority_h = priority_h.unwrap_or(self.priority_h);
self.priority_m = priority_m.unwrap_or(self.priority_m);
self.priority_l = priority_l.unwrap_or(self.priority_l);
self.priority_n = priority_n.unwrap_or(self.priority_n);

self.check()
}
Expand Down Expand Up @@ -218,6 +228,10 @@ impl KeyConfig {
&self.context_menu,
&self.next_tab,
&self.previous_tab,
&self.priority_h,
&self.priority_m,
&self.priority_l,
&self.priority_n,
Comment thread
cavanaug marked this conversation as resolved.
];
let l = elements.len();
elements.dedup();
Expand Down Expand Up @@ -258,4 +272,47 @@ fn has_just_one_char(s: &str) -> bool {
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_defaults_when_config_absent() {
let data = "";
let kc = KeyConfig::new(data).unwrap();
assert_eq!(kc.help, KeyCode::Char('?'));
assert_eq!(kc.priority_h, KeyCode::Char('H'));
assert_eq!(kc.priority_m, KeyCode::Char('M'));
assert_eq!(kc.priority_l, KeyCode::Char('L'));
assert_eq!(kc.priority_n, KeyCode::Char('N'));
}

#[test]
fn test_help_key_configurable() {
let data = "uda.taskwarrior-tui.keyconfig.help h\n";
let kc = KeyConfig::new(data).unwrap();
assert_eq!(kc.help, KeyCode::Char('h'));
}

#[test]
fn test_priority_keys_configurable() {
let data = "uda.taskwarrior-tui.keyconfig.priority-h 1\n\
uda.taskwarrior-tui.keyconfig.priority-m 2\n\
uda.taskwarrior-tui.keyconfig.priority-l 3\n\
uda.taskwarrior-tui.keyconfig.priority-n 4\n";
let kc = KeyConfig::new(data).unwrap();
Comment thread
cavanaug marked this conversation as resolved.
assert_eq!(kc.priority_h, KeyCode::Char('1'));
assert_eq!(kc.priority_m, KeyCode::Char('2'));
assert_eq!(kc.priority_l, KeyCode::Char('3'));
assert_eq!(kc.priority_n, KeyCode::Char('4'));
}

#[test]
fn test_existing_keys_still_work() {
let data = "uda.taskwarrior-tui.keyconfig.quit Q\n\
uda.taskwarrior-tui.keyconfig.add n\n";
Comment on lines +309 to +310

Copilot AI Feb 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the priority-keys test: the second line in this multi-line string literal is indented, so it will not match starts_with("uda.taskwarrior-tui.keyconfig.add") and kc.add will stay at its default, making the assertion fail. Make sure each config line begins at column 0 in the test data (or trim leading whitespace before matching in get_config()).

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Rust, a trailing \ on a string literal line consumes the newline and all leading whitespace on the next line. So "foo\n\ followed by an indented continuation produces "foo\nbar", not "foo\n bar". These tests pass as-is.

let kc = KeyConfig::new(data).unwrap();
assert_eq!(kc.quit, KeyCode::Char('Q'));
assert_eq!(kc.add, KeyCode::Char('n'));
// unset keys keep defaults
assert_eq!(kc.refresh, KeyCode::Char('r'));
assert_eq!(kc.down, KeyCode::Char('j'));
}
}