From 80b658e2474a96e92eccc510506818a197fc9fa1 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 18 Oct 2017 12:09:07 -0500 Subject: [PATCH] Work around OS X issue with dropped #fragment in launched URLs The previous hack used to work around an OS X issue/bug where launching a URL with a #fragment appended would drop the fragment by using `osascript` does not seem to work any more. Append the section name as a query string (in addition to, not instead of #section) and then use some basic javascript appended to the user doc HTML template to parse that and jump to the correct section (if the section was dropped). Closes #4480 --- doc_src/user_doc.footer.html | 10 ++++++++++ share/functions/help.fish | 21 +++++++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/doc_src/user_doc.footer.html b/doc_src/user_doc.footer.html index 308b1d01b..0a426c57a 100644 --- a/doc_src/user_doc.footer.html +++ b/doc_src/user_doc.footer.html @@ -1,2 +1,12 @@ + diff --git a/share/functions/help.fish b/share/functions/help.fish index d49ed87a4..8e9eecf2c 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -86,16 +86,18 @@ function help --description 'Show help for the fish shell' end switch "$fish_help_item" + # Issue #4480: OS X strips the #fragment when opening URLs, so we also pass it in as + # a query string and jump to the appropriate section with some very basic javascript case "." - set fish_help_page "commands.html\#source" + set fish_help_page "commands.html\?section=source\#source" case globbing - set fish_help_page "index.html\#expand" + set fish_help_page "index.html\?section=expand\#expand" case (__fish_print_commands) - set fish_help_page "commands.html\#$fish_help_item" + set fish_help_page "commands.html\?section=$fish_help_item\#$fish_help_item" case $help_topics - set fish_help_page "index.html\#$fish_help_item" + set fish_help_page "index.html\?section=$fish_help_item\#$fish_help_item" case 'tut_*' - set fish_help_page "tutorial.html\#$fish_help_item" + set fish_help_page "tutorial.html\?section=$fish_help_item\#$fish_help_item" case tutorial set fish_help_page "tutorial.html" case "*" @@ -129,15 +131,6 @@ function help --description 'Show help for the fish shell' set page_url https://fishshell.com/docs/$version_string/$fish_help_page end - # OS X /usr/bin/open swallows fragments (anchors), so use osascript - # Eval is just a cheesy way of removing the hash escaping - if test "$fish_browser" = osascript - set -l opencmd 'open location "'(eval echo $page_url)'"' - osascript -e 'try' -e $opencmd -e 'on error' -e $opencmd -e 'end try' - return - end - - # If browser is known to be graphical, put into background if contains -- $fish_browser[1] $graphical_browsers switch $fish_browser[1]