Skip to content

Commit

Permalink
Fixes #80382
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Sep 9, 2019
1 parent 332c4d9 commit 0041358
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
8 changes: 2 additions & 6 deletions src/vs/editor/browser/controller/coreCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down
12 changes: 4 additions & 8 deletions src/vs/editor/browser/view/viewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/controller/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/vs/editor/test/browser/controller/cursor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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, [
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit 0041358

Please sign in to comment.