swapper: Make quotes optional in key-value regex

The regular expression describing the tmux user options expects to find
quotes around the value. However, in at least tmux 3.0a the
`show-options -g` command doesn't display quotes around the values,
which means the regex fails.

For example, the current regex will fail to find these user options:

	$ tmux -V
	tmux 3.0a

	$ tmux show -g | grep -E "@thumbs"
	@thumbs-bg-color default
	@thumbs-fg-color green
	@thumbs-hint-bg-color default
	@thumbs-hint-fg-color blue
	@thumbs-select-bg-color default
	@thumbs-select-fg-color green

Make the quotes optional so that these options are picked up.

Fixes #33
This commit is contained in:
Thomas Preston 2020-05-09 13:38:02 +01:00 committed by Ferran Basora
parent 805a5ebe56
commit e006b06ea0

View File

@ -127,7 +127,7 @@ impl<'a> Swapper<'a> {
let options = self.executor.execute(params);
let lines: Vec<&str> = options.split('\n').collect();
let pattern = Regex::new(r#"@thumbs-([\w\-0-9]+) "(.*)""#).unwrap();
let pattern = Regex::new(r#"@thumbs-([\w\-0-9]+) "?(\w+)"?"#).unwrap();
let args = lines
.iter()