Mercurial > octave
changeset 33269:28c7f3195d3a
All Command Window right-click menu to search documentation for multi-word pattern (bug #65518)
* QTerminal.cc (handleCustomContextMenuRequested): Use a different
regexp to trim selected text of leading and trailing whitespace and
use that for the Documentation menu item.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 28 Mar 2024 11:26:47 -0700 |
parents | 95c195edc257 |
children | 65d2a1f70155 |
files | libgui/qterminal/libqterminal/QTerminal.cc |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/QTerminal.cc Thu Mar 28 19:00:01 2024 -0400 +++ b/libgui/qterminal/libqterminal/QTerminal.cc Thu Mar 28 11:26:47 2024 -0700 @@ -107,7 +107,8 @@ if (has_selected_text) { - QRegularExpression expr {"(\\w+)"}; + // Find first word in selected text, trim everything else + QRegularExpression expr {"^\\s*(\\w+)"}; QRegularExpressionMatch match = expr.match (selected_text); if (match.hasMatch ()) @@ -122,6 +123,10 @@ m_help_selected_action->setText (tr ("Help on %1").arg (expr_found)); m_help_selected_action->setData (expr_found); + // Grab all of selected text, but trim leading/trailing whitespace + expr.setPattern ("^\\s*(\\w.*)\\s*$"); + match = expr.match (selected_text); + expr_found = match.captured (1); m_doc_selected_action->setVisible (true); m_doc_selected_action->setText (tr ("Documentation on %1") .arg (expr_found));