mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Merge pull request #4581 from mqudsi/help_section_workaround
Work around OS X issue with dropped #fragment in launched URLs
This commit is contained in:
commit
ae700c8707
2 changed files with 17 additions and 14 deletions
|
@ -1,2 +1,12 @@
|
||||||
</body>
|
</body>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
// Some platforms don't handle launching a browser to navigate a page with
|
||||||
|
// a #fragment specified, so we use this workaround combined with a query string.
|
||||||
|
// See https://github.com/fish-shell/fish-shell/issues/4480
|
||||||
|
var params = new URLSearchParams(window.location.search); //?section=foo
|
||||||
|
var section = params.get("section");
|
||||||
|
if (section != null && location.hash == "") {
|
||||||
|
location.hash = "#" + section;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -86,16 +86,18 @@ function help --description 'Show help for the fish shell'
|
||||||
end
|
end
|
||||||
|
|
||||||
switch "$fish_help_item"
|
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 "."
|
case "."
|
||||||
set fish_help_page "commands.html\#source"
|
set fish_help_page "commands.html\?section=source\#source"
|
||||||
case globbing
|
case globbing
|
||||||
set fish_help_page "index.html\#expand"
|
set fish_help_page "index.html\?section=expand\#expand"
|
||||||
case (__fish_print_commands)
|
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
|
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_*'
|
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
|
case tutorial
|
||||||
set fish_help_page "tutorial.html"
|
set fish_help_page "tutorial.html"
|
||||||
case "*"
|
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
|
set page_url https://fishshell.com/docs/$version_string/$fish_help_page
|
||||||
end
|
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 browser is known to be graphical, put into background
|
||||||
if contains -- $fish_browser[1] $graphical_browsers
|
if contains -- $fish_browser[1] $graphical_browsers
|
||||||
switch $fish_browser[1]
|
switch $fish_browser[1]
|
||||||
|
|
Loading…
Reference in a new issue