mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-27 07:10:30 -04:00
Merge from master
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./dnd';
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
@@ -20,6 +18,7 @@ import { DragAndDropCommand } from 'vs/editor/contrib/dnd/dragAndDropCommand';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { IModelDeltaDecoration } from 'vs/editor/common/model';
|
||||
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
|
||||
function hasTriggerModifier(e: IKeyboardEvent | IMouseEvent): boolean {
|
||||
if (isMacintosh) {
|
||||
@@ -35,7 +34,7 @@ export class DragAndDropController implements editorCommon.IEditorContribution {
|
||||
|
||||
private _editor: ICodeEditor;
|
||||
private _toUnhook: IDisposable[];
|
||||
private _dragSelection: Selection;
|
||||
private _dragSelection: Selection | null;
|
||||
private _dndDecorationIds: string[];
|
||||
private _mouseDown: boolean;
|
||||
private _modiferPressed: boolean;
|
||||
@@ -54,12 +53,20 @@ export class DragAndDropController implements editorCommon.IEditorContribution {
|
||||
this._toUnhook.push(this._editor.onMouseDrop((e: IEditorMouseEvent) => this._onEditorMouseDrop(e)));
|
||||
this._toUnhook.push(this._editor.onKeyDown((e: IKeyboardEvent) => this.onEditorKeyDown(e)));
|
||||
this._toUnhook.push(this._editor.onKeyUp((e: IKeyboardEvent) => this.onEditorKeyUp(e)));
|
||||
this._toUnhook.push(this._editor.onDidBlurEditorWidget(() => this.onEditorBlur()));
|
||||
this._dndDecorationIds = [];
|
||||
this._mouseDown = false;
|
||||
this._modiferPressed = false;
|
||||
this._dragSelection = null;
|
||||
}
|
||||
|
||||
private onEditorBlur() {
|
||||
this._removeDecoration();
|
||||
this._dragSelection = null;
|
||||
this._mouseDown = false;
|
||||
this._modiferPressed = false;
|
||||
}
|
||||
|
||||
private onEditorKeyDown(e: IKeyboardEvent): void {
|
||||
if (!this._editor.getConfiguration().dragAndDrop) {
|
||||
return;
|
||||
@@ -108,7 +115,8 @@ export class DragAndDropController implements editorCommon.IEditorContribution {
|
||||
let target = mouseEvent.target;
|
||||
|
||||
if (this._dragSelection === null) {
|
||||
let possibleSelections = this._editor.getSelections().filter(selection => selection.containsPosition(target.position));
|
||||
const selections = this._editor.getSelections() || [];
|
||||
let possibleSelections = selections.filter(selection => target.position && selection.containsPosition(target.position));
|
||||
if (possibleSelections.length === 1) {
|
||||
this._dragSelection = possibleSelections[0];
|
||||
} else {
|
||||
@@ -126,10 +134,12 @@ export class DragAndDropController implements editorCommon.IEditorContribution {
|
||||
});
|
||||
}
|
||||
|
||||
if (this._dragSelection.containsPosition(target.position)) {
|
||||
this._removeDecoration();
|
||||
} else {
|
||||
this.showAt(target.position);
|
||||
if (target.position) {
|
||||
if (this._dragSelection.containsPosition(target.position)) {
|
||||
this._removeDecoration();
|
||||
} else {
|
||||
this.showAt(target.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,20 +148,24 @@ export class DragAndDropController implements editorCommon.IEditorContribution {
|
||||
let newCursorPosition = new Position(mouseEvent.target.position.lineNumber, mouseEvent.target.position.column);
|
||||
|
||||
if (this._dragSelection === null) {
|
||||
let newSelections: Selection[] | null = null;
|
||||
if (mouseEvent.event.shiftKey) {
|
||||
let primarySelection = this._editor.getSelection();
|
||||
let { startLineNumber, startColumn } = primarySelection;
|
||||
this._editor.setSelections([new Selection(startLineNumber, startColumn, newCursorPosition.lineNumber, newCursorPosition.column)]);
|
||||
if (primarySelection) {
|
||||
const { selectionStartLineNumber, selectionStartColumn } = primarySelection;
|
||||
newSelections = [new Selection(selectionStartLineNumber, selectionStartColumn, newCursorPosition.lineNumber, newCursorPosition.column)];
|
||||
}
|
||||
} else {
|
||||
let newSelections = this._editor.getSelections().map(selection => {
|
||||
newSelections = (this._editor.getSelections() || []).map(selection => {
|
||||
if (selection.containsPosition(newCursorPosition)) {
|
||||
return new Selection(newCursorPosition.lineNumber, newCursorPosition.column, newCursorPosition.lineNumber, newCursorPosition.column);
|
||||
} else {
|
||||
return selection;
|
||||
}
|
||||
});
|
||||
this._editor.setSelections(newSelections);
|
||||
}
|
||||
// Use `mouse` as the source instead of `api`.
|
||||
(<CodeEditorWidget>this._editor).setSelections(newSelections || [], 'mouse');
|
||||
} else if (!this._dragSelection.containsPosition(newCursorPosition) ||
|
||||
(
|
||||
(
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
|
||||
Reference in New Issue
Block a user