Merge branch 'master' into dispose-old-modehandlers

This commit is contained in:
Sean Kelly 2017-10-11 15:06:11 -07:00 committed by GitHub
commit 9aa47b2365

View File

@ -882,24 +882,12 @@ class CommandOverrideCopy extends BaseCommand {
public async exec(position: Position, vimState: VimState): Promise<VimState> {
let text = '';
if (
vimState.currentMode === ModeName.Visual ||
vimState.currentMode === ModeName.Normal ||
vimState.currentMode === ModeName.Insert
) {
if (vimState.currentMode === ModeName.Visual || vimState.currentMode === ModeName.Normal) {
text = vimState.allCursors
.map(range => {
const start = Position.EarlierOf(range.start, range.stop);
const stop = Position.LaterOf(range.start, range.stop);
// Insert selecting from the left to the right is a special case that
// selects one more on the right.
// The order of the if statements is to check for the case where start=stop
if (vimState.currentMode !== ModeName.Insert || start.isEqual(range.stop)) {
return vimState.editor.document.getText(new vscode.Range(start, stop.getRight()));
} else {
return vimState.editor.document.getText(new vscode.Range(start, stop));
}
return vimState.editor.document.getText(new vscode.Range(start, stop.getRight()));
})
.join('\n');
} else if (vimState.currentMode === ModeName.VisualLine) {
@ -917,6 +905,12 @@ 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);