Merge branch 'hcraT-master'
This commit is contained in:
commit
6014a963d4
@ -23,6 +23,11 @@ Added
|
|||||||
- New `--quiet` argument for the `:debug-pyeval` command to not open a tab with
|
- New `--quiet` argument for the `:debug-pyeval` command to not open a tab with
|
||||||
the results. Note `:debug-pyeval` is still only intended for debugging.
|
the results. Note `:debug-pyeval` is still only intended for debugging.
|
||||||
|
|
||||||
|
Changed
|
||||||
|
~~~~~~~
|
||||||
|
|
||||||
|
- Pasting multiple lines via `:paste` now opens each line in a new tab.
|
||||||
|
|
||||||
Fixed
|
Fixed
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|
||||||
|
@ -160,6 +160,7 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* ZDarian
|
* ZDarian
|
||||||
* John ShaggyTwoDope Jenkins
|
* John ShaggyTwoDope Jenkins
|
||||||
* Peter Vilim
|
* Peter Vilim
|
||||||
|
* Tarcisio Fedrizzi
|
||||||
* Jonas Schürmann
|
* Jonas Schürmann
|
||||||
* Panagiotis Ktistakis
|
* Panagiotis Ktistakis
|
||||||
* Jimmy
|
* Jimmy
|
||||||
|
@ -402,6 +402,8 @@ Syntax: +:paste [*--sel*] [*--tab*] [*--bg*] [*--window*]+
|
|||||||
|
|
||||||
Open a page from the clipboard.
|
Open a page from the clipboard.
|
||||||
|
|
||||||
|
If the pasted text contains newlines, each line gets opened in its own tab.
|
||||||
|
|
||||||
==== optional arguments
|
==== optional arguments
|
||||||
* +*-s*+, +*--sel*+: Use the primary selection instead of the clipboard.
|
* +*-s*+, +*--sel*+: Use the primary selection instead of the clipboard.
|
||||||
* +*-t*+, +*--tab*+: Open in a new tab.
|
* +*-t*+, +*--tab*+: Open in a new tab.
|
||||||
|
@ -809,6 +809,9 @@ class CommandDispatcher:
|
|||||||
def paste(self, sel=False, tab=False, bg=False, window=False):
|
def paste(self, sel=False, tab=False, bg=False, window=False):
|
||||||
"""Open a page from the clipboard.
|
"""Open a page from the clipboard.
|
||||||
|
|
||||||
|
If the pasted text contains newlines, each line gets opened in its own
|
||||||
|
tab.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
sel: Use the primary selection instead of the clipboard.
|
sel: Use the primary selection instead of the clipboard.
|
||||||
tab: Open in a new tab.
|
tab: Open in a new tab.
|
||||||
@ -825,12 +828,18 @@ class CommandDispatcher:
|
|||||||
text = clipboard.text(mode)
|
text = clipboard.text(mode)
|
||||||
if not text:
|
if not text:
|
||||||
raise cmdexc.CommandError("{} is empty.".format(target))
|
raise cmdexc.CommandError("{} is empty.".format(target))
|
||||||
log.misc.debug("{} contained: '{}'".format(target, text))
|
log.misc.debug("{} contained: '{}'".format(target,
|
||||||
try:
|
text.replace('\n', '\\n')))
|
||||||
url = urlutils.fuzzy_url(text)
|
text_urls = enumerate(u for u in text.split('\n') if u)
|
||||||
except urlutils.InvalidUrlError as e:
|
for i, text_url in text_urls:
|
||||||
raise cmdexc.CommandError(e)
|
if not window and i > 0:
|
||||||
self._open(url, tab, bg, window)
|
tab = False
|
||||||
|
bg = True
|
||||||
|
try:
|
||||||
|
url = urlutils.fuzzy_url(text_url)
|
||||||
|
except urlutils.InvalidUrlError as e:
|
||||||
|
raise cmdexc.CommandError(e)
|
||||||
|
self._open(url, tab, bg, window)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||||
count='count')
|
count='count')
|
||||||
|
@ -168,6 +168,7 @@ def fuzzy_url(urlstr, cwd=None, relative=False, do_search=True):
|
|||||||
Return:
|
Return:
|
||||||
A target QUrl to a search page or the original URL.
|
A target QUrl to a search page or the original URL.
|
||||||
"""
|
"""
|
||||||
|
urlstr = urlstr.strip()
|
||||||
expanded = os.path.expanduser(urlstr)
|
expanded = os.path.expanduser(urlstr)
|
||||||
if os.path.isabs(expanded):
|
if os.path.isabs(expanded):
|
||||||
path = expanded
|
path = expanded
|
||||||
@ -181,11 +182,10 @@ def fuzzy_url(urlstr, cwd=None, relative=False, do_search=True):
|
|||||||
else:
|
else:
|
||||||
path = None
|
path = None
|
||||||
|
|
||||||
stripped = urlstr.strip()
|
|
||||||
if path is not None and os.path.exists(path):
|
if path is not None and os.path.exists(path):
|
||||||
log.url.debug("URL is a local file")
|
log.url.debug("URL is a local file")
|
||||||
url = QUrl.fromLocalFile(path)
|
url = QUrl.fromLocalFile(path)
|
||||||
elif (not do_search) or is_url(stripped):
|
elif (not do_search) or is_url(urlstr):
|
||||||
# probably an address
|
# probably an address
|
||||||
log.url.debug("URL is a fuzzy address")
|
log.url.debug("URL is a fuzzy address")
|
||||||
url = qurl_from_user_input(urlstr)
|
url = qurl_from_user_input(urlstr)
|
||||||
@ -194,7 +194,7 @@ def fuzzy_url(urlstr, cwd=None, relative=False, do_search=True):
|
|||||||
try:
|
try:
|
||||||
url = _get_search_url(urlstr)
|
url = _get_search_url(urlstr)
|
||||||
except ValueError: # invalid search engine
|
except ValueError: # invalid search engine
|
||||||
url = qurl_from_user_input(stripped)
|
url = qurl_from_user_input(urlstr)
|
||||||
log.url.debug("Converting fuzzy term {} to URL -> {}".format(
|
log.url.debug("Converting fuzzy term {} to URL -> {}".format(
|
||||||
urlstr, url.toDisplayString()))
|
urlstr, url.toDisplayString()))
|
||||||
if do_search and config.get('general', 'auto-search'):
|
if do_search and config.get('general', 'auto-search'):
|
||||||
|
@ -25,6 +25,7 @@ import json
|
|||||||
import os.path
|
import os.path
|
||||||
import logging
|
import logging
|
||||||
import collections
|
import collections
|
||||||
|
import textwrap
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import yaml
|
import yaml
|
||||||
@ -207,6 +208,13 @@ def fill_clipboard(qtbot, qapp, httpbin, what, content):
|
|||||||
clipboard.setText(content, mode)
|
clipboard.setText(content, mode)
|
||||||
|
|
||||||
|
|
||||||
|
@bdd.when(bdd.parsers.re(r'I put the following lines into the '
|
||||||
|
r'(?P<what>primary selection|clipboard):\n'
|
||||||
|
r'(?P<content>.+)$', flags=re.DOTALL))
|
||||||
|
def fill_clipboard_multiline(qtbot, qapp, httpbin, what, content):
|
||||||
|
fill_clipboard(qtbot, qapp, httpbin, what, textwrap.dedent(content))
|
||||||
|
|
||||||
|
|
||||||
## Then
|
## Then
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,3 +104,69 @@ Feature: Yanking and pasting.
|
|||||||
And I put "foo bar" into the clipboard
|
And I put "foo bar" into the clipboard
|
||||||
And I run :paste
|
And I run :paste
|
||||||
Then the error "Invalid URL" should be shown
|
Then the error "Invalid URL" should be shown
|
||||||
|
|
||||||
|
Scenario: Pasting multiple urls in a new tab
|
||||||
|
Given I have a fresh instance
|
||||||
|
When I put the following lines into the clipboard:
|
||||||
|
http://localhost:(port)/data/hello.txt
|
||||||
|
http://localhost:(port)/data/hello2.txt
|
||||||
|
http://localhost:(port)/data/hello3.txt
|
||||||
|
And I run :paste -t
|
||||||
|
And I wait until data/hello.txt is loaded
|
||||||
|
And I wait until data/hello2.txt is loaded
|
||||||
|
And I wait until data/hello3.txt is loaded
|
||||||
|
Then the following tabs should be open:
|
||||||
|
- about:blank
|
||||||
|
- data/hello.txt (active)
|
||||||
|
- data/hello2.txt
|
||||||
|
- data/hello3.txt
|
||||||
|
|
||||||
|
Scenario: Pasting multiple urls in a background tab
|
||||||
|
Given I open about:blank
|
||||||
|
When I run :tab-only
|
||||||
|
And I put the following lines into the clipboard:
|
||||||
|
http://localhost:(port)/data/hello.txt
|
||||||
|
http://localhost:(port)/data/hello2.txt
|
||||||
|
http://localhost:(port)/data/hello3.txt
|
||||||
|
And I run :paste -b
|
||||||
|
And I wait until data/hello.txt is loaded
|
||||||
|
And I wait until data/hello2.txt is loaded
|
||||||
|
And I wait until data/hello3.txt is loaded
|
||||||
|
Then the following tabs should be open:
|
||||||
|
- about:blank (active)
|
||||||
|
- data/hello.txt
|
||||||
|
- data/hello2.txt
|
||||||
|
- data/hello3.txt
|
||||||
|
|
||||||
|
Scenario: Pasting multiple urls in new windows
|
||||||
|
Given I have a fresh instance
|
||||||
|
When I put the following lines into the clipboard:
|
||||||
|
http://localhost:(port)/data/hello.txt
|
||||||
|
http://localhost:(port)/data/hello2.txt
|
||||||
|
http://localhost:(port)/data/hello3.txt
|
||||||
|
And I run :paste -w
|
||||||
|
And I wait until data/hello.txt is loaded
|
||||||
|
And I wait until data/hello2.txt is loaded
|
||||||
|
And I wait until data/hello3.txt is loaded
|
||||||
|
Then the session should look like:
|
||||||
|
windows:
|
||||||
|
- tabs:
|
||||||
|
- active: true
|
||||||
|
history:
|
||||||
|
- active: true
|
||||||
|
url: about:blank
|
||||||
|
- tabs:
|
||||||
|
- active: true
|
||||||
|
history:
|
||||||
|
- active: true
|
||||||
|
url: http://localhost:*/data/hello.txt
|
||||||
|
- tabs:
|
||||||
|
- active: true
|
||||||
|
history:
|
||||||
|
- active: true
|
||||||
|
url: http://localhost:*/data/hello2.txt
|
||||||
|
- tabs:
|
||||||
|
- active: true
|
||||||
|
history:
|
||||||
|
- active: true
|
||||||
|
url: http://localhost:*/data/hello3.txt
|
||||||
|
@ -166,13 +166,17 @@ class TestFuzzyUrl:
|
|||||||
assert not os_mock.path.exists.called
|
assert not os_mock.path.exists.called
|
||||||
assert url == QUrl('http://foo')
|
assert url == QUrl('http://foo')
|
||||||
|
|
||||||
def test_file_absolute(self, os_mock):
|
@pytest.mark.parametrize('path, expected', [
|
||||||
|
('/foo', QUrl('file:///foo')),
|
||||||
|
('/bar\n', QUrl('file:///bar')),
|
||||||
|
])
|
||||||
|
def test_file_absolute(self, path, expected, os_mock):
|
||||||
"""Test with an absolute path."""
|
"""Test with an absolute path."""
|
||||||
os_mock.path.exists.return_value = True
|
os_mock.path.exists.return_value = True
|
||||||
os_mock.path.isabs.return_value = True
|
os_mock.path.isabs.return_value = True
|
||||||
|
|
||||||
url = urlutils.fuzzy_url('/foo')
|
url = urlutils.fuzzy_url(path)
|
||||||
assert url == QUrl('file:///foo')
|
assert url == expected
|
||||||
|
|
||||||
@pytest.mark.posix
|
@pytest.mark.posix
|
||||||
def test_file_absolute_expanded(self, os_mock):
|
def test_file_absolute_expanded(self, os_mock):
|
||||||
|
Loading…
Reference in New Issue
Block a user