diff --git a/config/src/lib.rs b/config/src/lib.rs index a7abab74e..ce200df56 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -842,6 +842,13 @@ pub struct Config { #[serde(default)] pub native_macos_fullscreen_mode: bool, + + #[serde(default = "default_word_boundary")] + pub selection_word_boundary: String, +} + +fn default_word_boundary() -> String { + " \t\n{[}]()\"'".to_string() } fn default_one_point_oh_f64() -> f64 { diff --git a/docs/changelog.markdown b/docs/changelog.markdown index 736bc70c9..25281f01a 100644 --- a/docs/changelog.markdown +++ b/docs/changelog.markdown @@ -36,6 +36,7 @@ brief notes about them may accumulate here. * X11: fix an issue where keys that produce unicode characters retained SHIFT as a modifier instead of normalizing it away. [#394](https://github.com/wez/wezterm/issues/394) * Fixed an issue where a symbol-only font would be seen as 0-width and panic wezterm [#404](https://github.com/wez/wezterm/issues/404) * Tweaked mouse selection: we now round the x-coordinate to the nearest cell which makes it a bit more forgiving if the mouse cursor is slightly to the left of the intended cell start. [#350](https://github.com/wez/wezterm/issues/350) +* Added `selection_word_boundary` option to control double-click word selection boundaries. The default is ` \t\n{[}]()\"'`. [#405](https://github.com/wez/wezterm/issues/405) ### 20201101-103216-403d002d diff --git a/wezterm-gui/src/gui/selection.rs b/wezterm-gui/src/gui/selection.rs index 1e565dded..612b7d0f2 100644 --- a/wezterm-gui/src/gui/selection.rs +++ b/wezterm-gui/src/gui/selection.rs @@ -51,13 +51,9 @@ pub struct SelectionRange { pub end: SelectionCoordinate, } -// TODO: expose is_double_click_word in config file fn is_double_click_word(s: &str) -> bool { match s.len() { - 1 => match s.chars().nth(0).unwrap() { - ' ' | '\t' | '\n' | '{' | '[' | '}' | ']' | '(' | ')' | '"' | '\'' => false, - _ => true, - }, + 1 => !config::configuration().selection_word_boundary.contains(s), 0 => false, _ => true, }