From 19c6e207059928e3c42da1652fca82a5736505b9 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Tue, 10 Oct 2017 09:39:36 +0200 Subject: [PATCH 1/2] Bugfix #1951: text selection in insert mode Use the normal selection in insert mode. This fixes #1951. Selection in insert mode seems to be specific to this plugin and is not easily possible in normal Vim. --- src/actions/commands/actions.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts index e6cdb5e4582..cfefa4154bd 100644 --- a/src/actions/commands/actions.ts +++ b/src/actions/commands/actions.ts @@ -884,8 +884,7 @@ class CommandOverrideCopy extends BaseCommand { if ( vimState.currentMode === ModeName.Visual || - vimState.currentMode === ModeName.Normal || - vimState.currentMode === ModeName.Insert + vimState.currentMode === ModeName.Normal ) { text = vimState.allCursors .map(range => { @@ -917,6 +916,10 @@ class CommandOverrideCopy extends BaseCommand { for (const { line } of Position.IterateLine(vimState)) { text += line + '\n'; } + } else if (vimState.currentMode === ModeName.Insert) { + text = vimState.editor.selections.map(selection => { + return vimState.editor.document.getText(new vscode.Range(selection.start, selection.end)); + }).join('\n'); } util.clipboardCopy(text); From b20cd05953918f0310fcb446255cb4c59040aade Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Wed, 11 Oct 2017 09:52:51 +0200 Subject: [PATCH 2/2] manually ran prettier --- src/actions/commands/actions.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts index cfefa4154bd..d252ed45058 100644 --- a/src/actions/commands/actions.ts +++ b/src/actions/commands/actions.ts @@ -882,10 +882,7 @@ class CommandOverrideCopy extends BaseCommand { public async exec(position: Position, vimState: VimState): Promise { let text = ''; - if ( - vimState.currentMode === ModeName.Visual || - vimState.currentMode === ModeName.Normal - ) { + if (vimState.currentMode === ModeName.Visual || vimState.currentMode === ModeName.Normal) { text = vimState.allCursors .map(range => { const start = Position.EarlierOf(range.start, range.stop); @@ -917,9 +914,11 @@ class CommandOverrideCopy extends BaseCommand { text += line + '\n'; } } else if (vimState.currentMode === ModeName.Insert) { - text = vimState.editor.selections.map(selection => { - return vimState.editor.document.getText(new vscode.Range(selection.start, selection.end)); - }).join('\n'); + text = vimState.editor.selections + .map(selection => { + return vimState.editor.document.getText(new vscode.Range(selection.start, selection.end)); + }) + .join('\n'); } util.clipboardCopy(text);