Leave mode when yanking by default.

See #653.
This commit is contained in:
Florian Bruhin 2015-05-13 07:58:33 +02:00
parent 866b299fef
commit f59a147589
2 changed files with 4 additions and 5 deletions

View File

@ -1389,12 +1389,12 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', hide=True,
modes=[KeyMode.caret], scope='window')
def yank_selected(self, sel=False, leave=False):
def yank_selected(self, sel=False, keep=False):
"""Yank the selected text to the clipboard or primary selection.
Args:
sel: Use the primary selection instead of the clipboard.
leave: If given, leave visual mode after yanking.
keep: If given, stay in visual mode after yanking.
"""
s = self._current_widget().selectedText()
if not self._current_widget().hasSelection() or len(s) == 0:
@ -1412,7 +1412,7 @@ class CommandDispatcher:
clipboard.setText(s, mode)
message.info(self._win_id, "{} {} yanked to {}".format(
len(s), "char" if len(s) == 1 else "chars", target))
if leave:
if not keep:
modeman.leave(self._win_id, KeyMode.caret, "yank selected")
@cmdutils.register(instance='command-dispatcher', hide=True,

View File

@ -1279,9 +1279,8 @@ KEY_DATA = collections.OrderedDict([
('move-to-end-of-line', ['$']),
('move-to-start-of-document', ['gg']),
('move-to-end-of-document', ['G']),
('yank-selected', ['y']),
('yank-selected -p', ['Y']),
('yank-selected --leave', ['<Return>', '<Ctrl-J>']),
('yank-selected', ['y', '<Return>', '<Ctrl-J>']),
('scroll -50 0', ['H']),
('scroll 0 50', ['J']),
('scroll 0 -50', ['K']),