提交 629cf657 编写于 作者: R rebornix

fix #97497.

上级 591039e3
......@@ -12,15 +12,17 @@ export class CopyLinesCommand implements ICommand {
private readonly _selection: Selection;
private readonly _isCopyingDown: boolean;
private readonly _noop: boolean;
private _selectionDirection: SelectionDirection;
private _selectionId: string | null;
private _startLineNumberDelta: number;
private _endLineNumberDelta: number;
constructor(selection: Selection, isCopyingDown: boolean) {
constructor(selection: Selection, isCopyingDown: boolean, noop?: boolean) {
this._selection = selection;
this._isCopyingDown = isCopyingDown;
this._noop = noop || false;
this._selectionDirection = SelectionDirection.LTR;
this._selectionId = null;
this._startLineNumberDelta = 0;
......@@ -51,10 +53,14 @@ export class CopyLinesCommand implements ICommand {
}
}
if (!this._isCopyingDown) {
builder.addEditOperation(new Range(s.endLineNumber, model.getLineMaxColumn(s.endLineNumber), s.endLineNumber, model.getLineMaxColumn(s.endLineNumber)), '\n' + sourceText);
if (this._noop) {
builder.addEditOperation(new Range(s.endLineNumber, model.getLineMaxColumn(s.endLineNumber), s.endLineNumber + 1, 1), '');
} else {
builder.addEditOperation(new Range(s.startLineNumber, 1, s.startLineNumber, 1), sourceText + '\n');
if (!this._isCopyingDown) {
builder.addEditOperation(new Range(s.endLineNumber, model.getLineMaxColumn(s.endLineNumber), s.endLineNumber, model.getLineMaxColumn(s.endLineNumber)), '\n' + sourceText);
} else {
builder.addEditOperation(new Range(s.startLineNumber, 1, s.startLineNumber, 1), sourceText + '\n');
}
}
this._selectionId = builder.trackSelection(s);
......
......@@ -18,7 +18,7 @@ import { Selection } from 'vs/editor/common/core/selection';
import { ICommand } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/model';
import { CopyLinesCommand } from 'vs/editor/contrib/linesOperations/copyLinesCommand';
import { CopyLinesCommand, NullCopyLinesCommand } from 'vs/editor/contrib/linesOperations/copyLinesCommand';
import { MoveLinesCommand } from 'vs/editor/contrib/linesOperations/moveLinesCommand';
import { SortLinesCommand } from 'vs/editor/contrib/linesOperations/sortLinesCommand';
import { MenuId } from 'vs/platform/actions/common/actions';
......@@ -63,10 +63,7 @@ abstract class AbstractCopyLinesAction extends EditorAction {
const commands: ICommand[] = [];
for (const selection of selections) {
if (selection.ignore) {
continue;
}
commands.push(new CopyLinesCommand(selection.selection, this.down));
commands.push(new CopyLinesCommand(selection.selection, this.down, selection.ignore));
}
editor.pushUndoStop();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册