Skip to content

Commit cdfbbdf

Browse files
committed
fix tmux keywords
1 parent 1c0acad commit cdfbbdf

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/tmux.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn capture_tmux_pane(pane_id: &str) -> Result<String, ()> {
4646
}
4747

4848
fn capture_alphanumeric_sequences(input: &str) -> Vec<String> {
49-
let re = Regex::new(r"[a-zA-Z0-9_\-\.]+").unwrap();
49+
let re = Regex::new(r"[a-zA-Z0-9][a-zA-Z0-9_\-\.]*").unwrap();
5050

5151
re.find_iter(input)
5252
.map(|mat| mat.as_str().to_string())
@@ -78,17 +78,16 @@ pub fn retrieve_tmux_words() -> Vec<String> {
7878
mod tests {
7979
#[test]
8080
fn test_is_tmux_executable() {
81-
assert!(super::is_tmux_executable());
81+
println!("{:?}", super::is_tmux_executable());
8282
}
8383

8484
#[test]
8585
fn test_list_tmux_panes() {
86-
// This test requires tmux server to be running
87-
// And at least one tmux window/pane to be opened
88-
// Otherwise it will return empty Vec
89-
let panes = super::list_tmux_panes();
90-
assert!(panes.len() > 0);
91-
println!("{:?}", panes);
86+
if super::is_tmux_executable() {
87+
let panes = super::list_tmux_panes();
88+
assert!(panes.len() > 0);
89+
println!("{:?}", panes);
90+
}
9291
}
9392

9493
#[test]
@@ -100,19 +99,23 @@ mod tests {
10099

101100
#[test]
102101
fn test_capture_tmux_pane() {
103-
let panes = super::list_tmux_panes();
104-
if panes.is_empty() {
105-
return;
102+
if super::is_tmux_executable() {
103+
let panes = super::list_tmux_panes();
104+
if panes.is_empty() {
105+
return;
106+
}
107+
let pane_id = &panes[0];
108+
let content = super::capture_tmux_pane(pane_id);
109+
assert!(content.is_ok());
106110
}
107-
let pane_id = &panes[0];
108-
let content = super::capture_tmux_pane(pane_id);
109-
assert!(content.is_ok());
110111
}
111112

112113
#[test]
113114
fn test_retrieve_tmux_words() {
114-
let words = super::retrieve_tmux_words();
115-
println!("{:?}", words);
116-
assert!(words.len() > 0);
115+
if super::is_tmux_executable() {
116+
let words = super::retrieve_tmux_words();
117+
println!("{:?}", words);
118+
assert!(words.len() > 0);
119+
}
117120
}
118121
}

0 commit comments

Comments
 (0)