This commit is contained in:
Alex Dima 2019-09-09 18:14:06 +02:00
parent 332c4d9f64
commit 0041358aee
4 changed files with 11 additions and 19 deletions

View file

@ -343,12 +343,8 @@ export namespace CoreNavigationCommands {
const validatedPosition = context.model.validatePosition(args.position);
const validatedViewPosition = context.validateViewPosition(new Position(args.viewPosition.lineNumber, args.viewPosition.column), validatedPosition);
let fromViewLineNumber = prevColumnSelectData.fromViewLineNumber;
let fromViewVisualColumn = prevColumnSelectData.fromViewVisualColumn;
if (!prevColumnSelectData.isReal && args.setAnchorIfNotSet) {
fromViewLineNumber = validatedViewPosition.lineNumber;
fromViewVisualColumn = args.mouseColumn - 1;
}
let fromViewLineNumber = args.doColumnSelect ? prevColumnSelectData.fromViewLineNumber : validatedViewPosition.lineNumber;
let fromViewVisualColumn = args.doColumnSelect ? prevColumnSelectData.fromViewVisualColumn : args.mouseColumn - 1;
return ColumnSelection.columnSelect(context.config, context.viewModel, fromViewLineNumber, fromViewVisualColumn, validatedViewPosition.lineNumber, args.mouseColumn - 1);
}
});

View file

@ -133,11 +133,7 @@ export class ViewController {
public dispatchMouse(data: IMouseDispatchData): void {
if (data.middleButton) {
if (data.inSelectionMode) {
this._columnSelect(data.position, data.mouseColumn, true);
} else {
this.moveTo(data.position);
}
this._columnSelect(data.position, data.mouseColumn, data.inSelectionMode);
} else if (data.startedOnLineNumbers) {
// If the dragging started on the gutter, then have operations work on the entire line
if (this._hasMulticursorModifier(data)) {
@ -183,7 +179,7 @@ export class ViewController {
if (this._hasMulticursorModifier(data)) {
if (!this._hasNonMulticursorModifier(data)) {
if (data.shiftKey) {
this._columnSelect(data.position, data.mouseColumn, false);
this._columnSelect(data.position, data.mouseColumn, true);
} else {
// Do multi-cursor operations only when purely alt is pressed
if (data.inSelectionMode) {
@ -223,13 +219,13 @@ export class ViewController {
this._execMouseCommand(CoreNavigationCommands.MoveToSelect, this._usualArgs(viewPosition));
}
private _columnSelect(viewPosition: Position, mouseColumn: number, setAnchorIfNotSet: boolean): void {
private _columnSelect(viewPosition: Position, mouseColumn: number, doColumnSelect: boolean): void {
viewPosition = this._validateViewColumn(viewPosition);
this._execMouseCommand(CoreNavigationCommands.ColumnSelect, {
position: this._convertViewToModelPosition(viewPosition),
viewPosition: viewPosition,
mouseColumn: mouseColumn,
setAnchorIfNotSet: setAnchorIfNotSet
doColumnSelect: doColumnSelect
});
}

View file

@ -400,7 +400,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return this._columnSelectData;
}
const primaryCursor = this._cursors.getPrimaryCursor();
const primaryPos = primaryCursor.viewState.position;
const primaryPos = primaryCursor.viewState.selectionStart.getStartPosition();
const viewLineNumber = primaryPos.lineNumber;
const viewVisualColumn = CursorColumns.visibleColumnFromColumn2(this.context.config, this.context.viewModel, primaryPos);
return {

View file

@ -711,7 +711,7 @@ suite('Editor Controller - Cursor', () => {
position: new Position(4, 4),
viewPosition: new Position(4, 4),
mouseColumn: 15,
setAnchorIfNotSet: false
doColumnSelect: true
});
let expectedSelections = [
@ -747,7 +747,7 @@ suite('Editor Controller - Cursor', () => {
position: new Position(4, 1),
viewPosition: new Position(4, 1),
mouseColumn: 1,
setAnchorIfNotSet: false
doColumnSelect: true
});
assertCursor(cursor, [
@ -787,7 +787,7 @@ suite('Editor Controller - Cursor', () => {
position: new Position(1, 1),
viewPosition: new Position(1, 1),
mouseColumn: 1,
setAnchorIfNotSet: false
doColumnSelect: true
});
assertCursor(cursor, [
new Selection(10, 10, 10, 1),
@ -806,7 +806,7 @@ suite('Editor Controller - Cursor', () => {
position: new Position(1, 1),
viewPosition: new Position(1, 1),
mouseColumn: 1,
setAnchorIfNotSet: false
doColumnSelect: true
});
assertCursor(cursor, [
new Selection(10, 10, 10, 1),