# HG changeset patch # User Rik # Date 1711650407 25200 # Node ID 28c7f3195d3afcb943a4913fd72524594036c78c # Parent 95c195edc257d2b6cc6d8aec7cbf572c79a19a49 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. diff -r 95c195edc257 -r 28c7f3195d3a libgui/qterminal/libqterminal/QTerminal.cc --- 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));