Skip to content

Commit cdecd36

Browse files
committed
Perform the search on selected text, if any
1 parent 391e548 commit cdecd36

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Commands/Documentation for Word.tmCommand

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
<string>#!/usr/bin/env bash
1111
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] &amp;&amp; . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
1212
13-
if grep &lt;&lt;&lt;${TM_CURRENT_WORD:-!} -Esq '^[a-zA-Z0-9_]+$'
13+
term=${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}
14+
15+
if grep &lt;&lt;&lt;${term} -Esq '^[a-zA-Z0-9_]+$'
1416
then
1517
if URL=`grep -i "^$TM_CURRENT_WORD=" "$TM_BUNDLE_SUPPORT/documentation.txt"`
1618
then
17-
URL=${URL:${#TM_CURRENT_WORD}+1}
19+
URL=${URL:${#term}+1}
1820
else
19-
URL="function.${TM_CURRENT_WORD//_/-}"
21+
URL="function.${term//_/-}"
2022
fi
2123
if [[ "$PHP_MANUAL_LOCATION" ]]
2224
then
@@ -26,7 +28,7 @@ if grep &lt;&lt;&lt;${TM_CURRENT_WORD:-!} -Esq '^[a-zA-Z0-9_]+$'
2628
fi
2729
if [[ ! -f "$PHP_MANUAL_LOCATION/$URL.html" ]]
2830
then
29-
exit_show_tool_tip "No documentation found for '$TM_CURRENT_WORD'"
31+
exit_show_tool_tip "No documentation found for '$term'"
3032
fi
3133
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
3234
html_header "PHP Help" "${TM_FILENAME:-}"
@@ -49,7 +51,7 @@ if grep &lt;&lt;&lt;${TM_CURRENT_WORD:-!} -Esq '^[a-zA-Z0-9_]+$'
4951
historyList.appendChild(item);
5052
item.selected = true;
5153
}
52-
54+
5355
function setupLinks() {
5456
var link, links = document.links;
5557
for (i = 0; i &lt; links.length; i++) {

0 commit comments

Comments
 (0)