From e514b0d58eeaf6f7de911ade7da0854c5c4a5769 Mon Sep 17 00:00:00 2001 From: thuck Date: Wed, 16 Nov 2016 08:18:08 +0100 Subject: [PATCH 1/5] Included --force option for tab-close This makes possible to close pinned tabs without any confirmation. --- qutebrowser/browser/commands.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 8dbe4fe86..567e45a9f 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -239,7 +239,8 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) - def tab_close(self, prev=False, next_=False, opposite=False, count=None): + def tab_close(self, prev=False, next_=False, opposite=False, + force=False, count=None): """Close the current/[count]th tab. Args: @@ -247,6 +248,7 @@ class CommandDispatcher: next_: Force selecting the tab after the current tab. opposite: Force selecting the tab in the opposite direction of what's configured in 'tabs->select-on-remove'. + force: Avoid confirmation for pinned tabs. count: The tab index to close, or None """ tab = self._cntwidget(count) @@ -255,7 +257,7 @@ class CommandDispatcher: close = functools.partial(self._tab_close, tab, prev, next_, opposite) - if tab.data.pinned: + if tab.data.pinned and not force: message.confirm_async(title='Pinned Tab', text="Are you sure you want to close a pinned tab?", yes_action=close, default=False) From 41adafdec49262ec24c4d5b8a854d1eccf235500 Mon Sep 17 00:00:00 2001 From: thuck Date: Wed, 16 Nov 2016 08:19:21 +0100 Subject: [PATCH 2/5] Fix initial tests --- tests/end2end/features/conftest.py | 2 +- tests/end2end/features/tabs.feature | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index 7dd42c2d0..517d77144 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -160,7 +160,7 @@ def clean_open_tabs(quteproc): quteproc.set_setting('tabs', 'last-close', 'blank') quteproc.send_cmd(':window-only') quteproc.send_cmd(':tab-only') - quteproc.send_cmd(':tab-close') + quteproc.send_cmd(':tab-close --force') @bdd.given('pdfjs is available') diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 2e8a00790..546eae425 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -1011,21 +1011,32 @@ Feature: Tab management - data/numbers/2.txt Scenario: :tab-pin unpin - When I run :tab-pin + When I open data/numbers/1.txt + And I open data/numbers/2.txt in a new tab + And I open data/numbers/3.txt in a new tab + And I run :tab-pin + And I run :tab-pin Then the following tabs should be open: - data/numbers/1.txt - data/numbers/2.txt - data/numbers/3.txt (active) Scenario: :tab-pin to index 2 - When I run :tab-pin 2 + When I open data/numbers/1.txt + And I open data/numbers/2.txt in a new tab + And I open data/numbers/3.txt in a new tab + And I run :tab-pin 2 Then the following tabs should be open: - data/numbers/1.txt - data/numbers/3.txt (active) - data/numbers/2.txt Scenario: :tab-pin unpin to index 1 - When I run :tab-pin 1 + When I open data/numbers/1.txt + And I open data/numbers/2.txt in a new tab + And I open data/numbers/3.txt in a new tab + And I run :tab-pin + And I run :tab-pin 1 Then the following tabs should be open: - data/numbers/3.txt (active) - data/numbers/1.txt From 69c82f85632ab13c4c3e1675583874944d3f7286 Mon Sep 17 00:00:00 2001 From: thuck Date: Fri, 18 Nov 2016 07:42:48 +0100 Subject: [PATCH 3/5] Including tests for pinned tab prompt Duplicate function for "I wait for a prompt" --- tests/end2end/features/tabs.feature | 23 +++++++++++++++++++++++ tests/end2end/features/test_tabs_bdd.py | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 546eae425..c4c1d56e4 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -1041,3 +1041,26 @@ Feature: Tab management - data/numbers/3.txt (active) - data/numbers/1.txt - data/numbers/2.txt + + Scenario: :tab-pin prompt yes + When I open data/numbers/1.txt + And I run :tab-pin + And I open data/numbers/2.txt in a new tab + And I run :tab-pin + And I run :tab-close + And I wait for a prompt + And I run :prompt-accept yes + Then the following tabs should be open: + - data/numbers/1.txt (active) + + Scenario: :tab-pin prompt no + When I open data/numbers/1.txt + And I run :tab-pin + And I open data/numbers/2.txt in a new tab + And I run :tab-pin + And I run :tab-close + And I wait for a prompt + And I run :prompt-accept no + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/2.txt (active) diff --git a/tests/end2end/features/test_tabs_bdd.py b/tests/end2end/features/test_tabs_bdd.py index bcae6d60d..a61dd4fcd 100644 --- a/tests/end2end/features/test_tabs_bdd.py +++ b/tests/end2end/features/test_tabs_bdd.py @@ -19,3 +19,7 @@ import pytest_bdd as bdd bdd.scenarios('tabs.feature') + +@bdd.when("I wait for a prompt") +def wait_for_prompt(quteproc): + quteproc.wait_for(message='Asking question *') From 175744761b7bdf66f797912167dc62da88954286 Mon Sep 17 00:00:00 2001 From: thuck Date: Tue, 22 Nov 2016 06:57:00 +0100 Subject: [PATCH 4/5] flake8 fixes --- qutebrowser/browser/commands.py | 2 +- tests/end2end/features/test_tabs_bdd.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 567e45a9f..8f71fe75a 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -240,7 +240,7 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.argument('count', count=True) def tab_close(self, prev=False, next_=False, opposite=False, - force=False, count=None): + force=False, count=None): """Close the current/[count]th tab. Args: diff --git a/tests/end2end/features/test_tabs_bdd.py b/tests/end2end/features/test_tabs_bdd.py index a61dd4fcd..d53241288 100644 --- a/tests/end2end/features/test_tabs_bdd.py +++ b/tests/end2end/features/test_tabs_bdd.py @@ -20,6 +20,7 @@ import pytest_bdd as bdd bdd.scenarios('tabs.feature') + @bdd.when("I wait for a prompt") def wait_for_prompt(quteproc): quteproc.wait_for(message='Asking question *') From 982e4f46e0d0dbd2887b203b3ecf2a402f42a0f5 Mon Sep 17 00:00:00 2001 From: thuck Date: Tue, 22 Nov 2016 07:24:02 +0100 Subject: [PATCH 5/5] Test for accidental url opened in a pinned tab --- tests/end2end/features/tabs.feature | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index c4c1d56e4..a2e903001 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -1064,3 +1064,11 @@ Feature: Tab management Then the following tabs should be open: - data/numbers/1.txt - data/numbers/2.txt (active) + + Scenario: :tab-pin open url + When I open data/numbers/1.txt + And I run :tab-pin + And I run :open data/numbers/2.txt + Then the message "Tab is pinned!" should be shown + And the following tabs should be open: + - data/numbers/1.txt (active)