Merge remote-tracking branch 'origin/pr/4438'

This commit is contained in:
Florian Bruhin 2020-08-03 16:05:39 +02:00
commit bd97768c37
6 changed files with 30 additions and 2 deletions

View File

@ -45,6 +45,8 @@ Changed
- `:back` and `:forward` now take an optional index which is completed using
the current tab's history.
- The time a website in a tab was visited is now saved/restored in sessions.
- New command `:navigate strip` which removes queries and parameters from the
current URL (bound to `gs`/`gS` by default).
Added
~~~~~

View File

@ -866,6 +866,7 @@ This tries to automatically click on typical _Previous Page_ or _Next Page_ link
Uses the
link:settings{outsuffix}#url.incdec_segments[url.incdec_segments]
config option.
- `strip`: Strip parameters from the current URL.

View File

@ -627,6 +627,7 @@ Default:
* +pass:[gC]+: +pass:[tab-clone]+
* +pass:[gD]+: +pass:[tab-give]+
* +pass:[gO]+: +pass:[set-cmd-text :open -t -r {url:pretty}]+
* +pass:[gS]+: +pass:[navigate strip -t]+
* +pass:[gU]+: +pass:[navigate up -t]+
* +pass:[g^]+: +pass:[tab-focus 1]+
* +pass:[ga]+: +pass:[open -t]+
@ -639,6 +640,7 @@ Default:
* +pass:[gm]+: +pass:[tab-move]+
* +pass:[go]+: +pass:[set-cmd-text :open {url:pretty}]+
* +pass:[gr]+: +pass:[tab-move +]+
* +pass:[gs]+: +pass:[navigate strip]+
* +pass:[gt]+: +pass:[set-cmd-text -s :buffer]+
* +pass:[gu]+: +pass:[navigate up]+
* +pass:[h]+: +pass:[scroll left]+

View File

@ -562,7 +562,7 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window')
@cmdutils.argument('where', choices=['prev', 'next', 'up', 'increment',
'decrement'])
'decrement', 'strip'])
@cmdutils.argument('count', value=cmdutils.Value.count)
def navigate(self, where: str, tab: bool = False, bg: bool = False,
window: bool = False, count: int = 1) -> None:
@ -587,6 +587,7 @@ class CommandDispatcher:
Uses the
link:settings{outsuffix}#url.incdec_segments[url.incdec_segments]
config option.
- `strip`: Strip parameters from the current URL.
tab: Open in a new tab.
bg: Open in a background tab.
@ -618,6 +619,9 @@ class CommandDispatcher:
url = url.adjusted(QUrl.RemoveFragment | QUrl.RemoveQuery)
new_url = handlers[where](url, count)
self._open(new_url, tab, bg, window, related=True)
elif where == 'strip':
url = url.adjusted(QUrl.RemoveFragment | QUrl.RemoveQuery)
self._open(url, tab, bg, window, related=True)
else: # pragma: no cover
raise ValueError("Got called with invalid value {} for "
"`where'.".format(where))

View File

@ -3177,6 +3177,8 @@ bindings.default:
"}}": navigate next -t
gu: navigate up
gU: navigate up -t
gs: navigate strip
gS: navigate strip -t
<Ctrl-A>: navigate increment
<Ctrl-X>: navigate decrement
wi: devtools

View File

@ -4,7 +4,7 @@ Feature: Using :navigate
Scenario: :navigate with invalid argument
When I run :navigate foo
Then the error "where: Invalid value foo - expected one of: prev, next, up, increment, decrement" should be shown
Then the error "where: Invalid value foo - expected one of: prev, next, up, increment, decrement, strip" should be shown
# up
@ -137,3 +137,20 @@ Feature: Using :navigate
When I open data/navigate/multilinelinks.html
And I run :navigate next
Then data/numbers/5.txt should be loaded
# strip
Scenario: Stripping a query
When I open data/navigate?foo=bar
And I run :navigate strip
Then data/navigate should be loaded
Scenario: Stripping a label
When I open data/navigate#label
And I run :navigate strip
Then data/navigate should be loaded
Scenario: Stripping a query and a label
When I open data/navigate?foo=bar#label
And I run :navigate strip
Then data/navigate should be loaded