Handle Shift-Insert correctly in prompt mode.

Fixes #1299.
This commit is contained in:
Florian Bruhin 2016-02-10 06:40:54 +01:00
parent d6267c30f6
commit b6f1dd963d
3 changed files with 28 additions and 13 deletions

View File

@ -36,6 +36,7 @@ Changed
- `:navigate increment/decrement` now preserves leading zeroes in URLs.
- `general -> editor` can now also handle `{}` inside another argument (e.g. to open `vim` via `termite`)
- Improved performance when scrolling with many tabs open.
- Shift-Insert now also pastes primary selection for prompts.
Fixed
~~~~~

View File

@ -42,6 +42,19 @@ class MinimalLineEditMixin:
""")
self.setAttribute(Qt.WA_MacShowFocusRect, False)
def keyPressEvent(self, e):
"""Override keyPressEvent to paste primary selection on Shift + Ins."""
if e.key() == Qt.Key_Insert and e.modifiers() == Qt.ShiftModifier:
try:
text = utils.get_clipboard(selection=True)
except utils.SelectionUnsupportedError:
pass
else:
e.accept()
self.insert(text)
return
super().keyPressEvent(e)
def __repr__(self):
return utils.get_repr(self)
@ -98,19 +111,6 @@ class CommandLineEdit(QLineEdit):
if mark:
self.setSelection(self._promptlen, oldpos - self._promptlen)
def keyPressEvent(self, e):
"""Override keyPressEvent to paste primary selection on Shift + Ins."""
if e.key() == Qt.Key_Insert and e.modifiers() == Qt.ShiftModifier:
try:
text = utils.get_clipboard(selection=True)
except utils.SelectionUnsupportedError:
pass
else:
e.accept()
self.insert(text)
return
super().keyPressEvent(e)
class _CommandValidator(QValidator):

View File

@ -58,6 +58,20 @@ Feature: Prompts
And I run :leave-mode
Then the javascript message "Prompt reply: null" should be logged
# Shift-Insert with prompt (issue 1299)
@pyqt531_or_newer
Scenario: Pasting via shift-insert in prompt mode
When selection is supported
And I put "insert test" into the primary selection
And I open data/prompt/jsprompt.html
And I click the button
And I wait for a prompt
And I press the keys "<Shift-Insert>"
And I run :prompt-accept
Then the javascript message "Prompt reply: insert test" should be logged
@pyqt531_or_newer
Scenario: Using content -> ignore-javascript-prompt
When I set content -> ignore-javascript-prompt to true