From 7a1f4af37423df60aa301a47d5e09d3cc6659083 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Mon, 29 Jun 2015 17:19:05 +0200 Subject: [PATCH 1/2] Change command filename to its in-app name --- ... word in PHP manual.plist => Documentation for Word.tmCommand} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Commands/{Lookup word in PHP manual.plist => Documentation for Word.tmCommand} (100%) diff --git a/Commands/Lookup word in PHP manual.plist b/Commands/Documentation for Word.tmCommand similarity index 100% rename from Commands/Lookup word in PHP manual.plist rename to Commands/Documentation for Word.tmCommand From 6c6d265426587e6eee9fc0bd7d71b16be51e37b3 Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Mon, 29 Jun 2015 17:20:20 +0200 Subject: [PATCH 2/2] Perform the search on selected text, if any --- Commands/Documentation for Word.tmCommand | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Commands/Documentation for Word.tmCommand b/Commands/Documentation for Word.tmCommand index 5d435a1..0f832f1 100644 --- a/Commands/Documentation for Word.tmCommand +++ b/Commands/Documentation for Word.tmCommand @@ -10,13 +10,15 @@ #!/usr/bin/env bash [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" -if grep <<<${TM_CURRENT_WORD:-!} -Esq '^[a-zA-Z0-9_]+$' +term=${TM_SELECTED_TEXT:-$TM_CURRENT_WORD} + +if grep <<<${term} -Esq '^[a-zA-Z0-9_]+$' then if URL=`grep -i "^$TM_CURRENT_WORD=" "$TM_BUNDLE_SUPPORT/documentation.txt"` then - URL=${URL:${#TM_CURRENT_WORD}+1} + URL=${URL:${#term}+1} else - URL="function.${TM_CURRENT_WORD//_/-}" + URL="function.${term//_/-}" fi if [[ "$PHP_MANUAL_LOCATION" ]] then @@ -26,7 +28,7 @@ if grep <<<${TM_CURRENT_WORD:-!} -Esq '^[a-zA-Z0-9_]+$' fi if [[ ! -f "$PHP_MANUAL_LOCATION/$URL.html" ]] then - exit_show_tool_tip "No documentation found for '$TM_CURRENT_WORD'" + exit_show_tool_tip "No documentation found for '$term'" fi . "$TM_SUPPORT_PATH/lib/webpreview.sh" html_header "PHP Help" "${TM_FILENAME:-}" @@ -49,7 +51,7 @@ if grep <<<${TM_CURRENT_WORD:-!} -Esq '^[a-zA-Z0-9_]+$' historyList.appendChild(item); item.selected = true; } - + function setupLinks() { var link, links = document.links; for (i = 0; i < links.length; i++) {