From 760864b6b2b1562266488bf068e0261e142e5b28 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 6 Apr 2023 15:50:24 -0700 Subject: [PATCH] quick select: make user patterns take precedence I think the future for this is to extend the Pattern type to accept a list of regexes and use a RegexSet to unambiguously handle multiple patterns with captures. That might help a little with https://github.com/wez/wezterm/issues/3247 but the stated use in that issue may not even work with the rust regex crate. For now we do the simple thing and match the user's patterns first. refs: https://github.com/wez/wezterm/issues/3456 --- docs/changelog.md | 2 ++ wezterm-gui/src/overlay/quickselect.rs | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 9f69ede21..73a172001 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -99,6 +99,8 @@ As features stabilize some brief notes about them will accumulate here. the local machine or vice versa. #3442 * `wezterm.config_builder` now works with `table.insert(config.keys, {..})` * mux: `wezterm cli activate-pane-direction` inconsistent behavior with remote mux. #3387 #3448 +* [quick_select_patterns](config/lua/config/quick_select_patterns.md) didn't + take precedence over built-in rules. #3456 ### 20230326-111934-3666303c diff --git a/wezterm-gui/src/overlay/quickselect.rs b/wezterm-gui/src/overlay/quickselect.rs index 889055858..753fa2a40 100644 --- a/wezterm-gui/src/overlay/quickselect.rs +++ b/wezterm-gui/src/overlay/quickselect.rs @@ -204,6 +204,14 @@ impl QuickSelectOverlay { have_patterns = true; } } else { + // User-provided patterns take precedence over built-ins + for p in &config.quick_select_patterns { + if have_patterns { + pattern.push('|'); + } + pattern.push_str(p); + have_patterns = true; + } if !config.disable_default_quick_select_patterns { for p in &PATTERNS { if have_patterns { @@ -213,13 +221,6 @@ impl QuickSelectOverlay { have_patterns = true; } } - for p in &config.quick_select_patterns { - if have_patterns { - pattern.push('|'); - } - pattern.push_str(p); - have_patterns = true; - } } pattern.push(')');