diff options
author | Tim Pope <code@tpope.net> | 2023-01-29 15:30:36 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-29 21:30:36 +0100 |
commit | 215e55408f3f4d50a1d5d8498f1a18f0442fc560 (patch) | |
tree | 2b842f7aec2159b207add5d058cbd33fcf7a402a | |
parent | fb7c8c71ef6e628ebe844e88bff39026719f4a25 (diff) |
[Script] Strip pango markup when matching rows (#1795)
This is effectively the same fix that was made to DMenu in
a42e9f869f8fe95772aace1544dcf907827a0e52.
-rw-r--r-- | source/modes/script.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/source/modes/script.c b/source/modes/script.c index 6661f999..8771e4d2 100644 --- a/source/modes/script.c +++ b/source/modes/script.c @@ -444,22 +444,36 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line, static int script_token_match(const Mode *sw, rofi_int_matcher **tokens, unsigned int index) { ScriptModePrivateData *rmpd = sw->private_data; - int match = 1; - if (tokens) { - for (int j = 0; match && tokens[j] != NULL; j++) { - rofi_int_matcher *ftokens[2] = {tokens[j], NULL}; - int test = 0; - test = helper_token_match(ftokens, rmpd->cmd_list[index].entry); - if (test == tokens[j]->invert && rmpd->cmd_list[index].meta) { - test = helper_token_match(ftokens, rmpd->cmd_list[index].meta); - } + /** Strip out the markup when matching. */ + char *esc = NULL; + if (rmpd->do_markup) { + pango_parse_markup(rmpd->cmd_list[index].entry, -1, 0, NULL, &esc, NULL, + NULL); + } else { + esc = rmpd->cmd_list[index].entry; + } + if (esc) { + int match = 1; + if (tokens) { + for (int j = 0; match && tokens[j] != NULL; j++) { + rofi_int_matcher *ftokens[2] = {tokens[j], NULL}; + int test = 0; + test = helper_token_match(ftokens, esc); + if (test == tokens[j]->invert && rmpd->cmd_list[index].meta) { + test = helper_token_match(ftokens, rmpd->cmd_list[index].meta); + } - if (test == 0) { - match = 0; + if (test == 0) { + match = 0; + } } } + if (rmpd->do_markup) { + g_free(esc); + } + return match; } - return match; + return FALSE; } static char *script_get_message(const Mode *sw) { ScriptModePrivateData *pd = sw->private_data; |