mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-18 19:11:36 -04:00
Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)
* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c * remove files we don't want * fix hygiene * update distro * update distro * fix hygiene * fix strict nulls * distro * distro * fix tests * fix tests * add another edit * fix viewlet icon * fix azure dialog * fix some padding * fix more padding issues
This commit is contained in:
@@ -64,7 +64,7 @@ class CopyLinesUpAction extends AbstractCopyLinesAction {
|
||||
linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.UpArrow },
|
||||
weight: KeybindingWeight.EditorContrib
|
||||
},
|
||||
menubarOpts: {
|
||||
menuOpts: {
|
||||
menuId: MenuId.MenubarSelectionMenu,
|
||||
group: '2_line',
|
||||
title: nls.localize({ key: 'miCopyLinesUp', comment: ['&& denotes a mnemonic'] }, "&&Copy Line Up"),
|
||||
@@ -87,7 +87,7 @@ class CopyLinesDownAction extends AbstractCopyLinesAction {
|
||||
linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyMod.Shift | KeyCode.DownArrow },
|
||||
weight: KeybindingWeight.EditorContrib
|
||||
},
|
||||
menubarOpts: {
|
||||
menuOpts: {
|
||||
menuId: MenuId.MenubarSelectionMenu,
|
||||
group: '2_line',
|
||||
title: nls.localize({ key: 'miCopyLinesDown', comment: ['&& denotes a mnemonic'] }, "Co&&py Line Down"),
|
||||
@@ -105,7 +105,7 @@ export class DuplicateSelectionAction extends EditorAction {
|
||||
label: nls.localize('duplicateSelection', "Duplicate Selection"),
|
||||
alias: 'Duplicate Selection',
|
||||
precondition: EditorContextKeys.writable,
|
||||
menubarOpts: {
|
||||
menuOpts: {
|
||||
menuId: MenuId.MenubarSelectionMenu,
|
||||
group: '2_line',
|
||||
title: nls.localize({ key: 'miDuplicateSelection', comment: ['&& denotes a mnemonic'] }, "&&Duplicate Selection"),
|
||||
@@ -178,7 +178,7 @@ class MoveLinesUpAction extends AbstractMoveLinesAction {
|
||||
linux: { primary: KeyMod.Alt | KeyCode.UpArrow },
|
||||
weight: KeybindingWeight.EditorContrib
|
||||
},
|
||||
menubarOpts: {
|
||||
menuOpts: {
|
||||
menuId: MenuId.MenubarSelectionMenu,
|
||||
group: '2_line',
|
||||
title: nls.localize({ key: 'miMoveLinesUp', comment: ['&& denotes a mnemonic'] }, "Mo&&ve Line Up"),
|
||||
@@ -201,7 +201,7 @@ class MoveLinesDownAction extends AbstractMoveLinesAction {
|
||||
linux: { primary: KeyMod.Alt | KeyCode.DownArrow },
|
||||
weight: KeybindingWeight.EditorContrib
|
||||
},
|
||||
menubarOpts: {
|
||||
menuOpts: {
|
||||
menuId: MenuId.MenubarSelectionMenu,
|
||||
group: '2_line',
|
||||
title: nls.localize({ key: 'miMoveLinesDown', comment: ['&& denotes a mnemonic'] }, "Move &&Line Down"),
|
||||
|
||||
@@ -13,18 +13,19 @@ import { IndentAction } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { IIndentConverter, LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import { IndentConsts } from 'vs/editor/common/modes/supports/indentRules';
|
||||
import * as indentUtils from 'vs/editor/contrib/indentation/indentUtils';
|
||||
import { EditorAutoIndentStrategy } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export class MoveLinesCommand implements ICommand {
|
||||
|
||||
private readonly _selection: Selection;
|
||||
private readonly _isMovingDown: boolean;
|
||||
private readonly _autoIndent: boolean;
|
||||
private readonly _autoIndent: EditorAutoIndentStrategy;
|
||||
|
||||
private _selectionId: string | null;
|
||||
private _moveEndPositionDown?: boolean;
|
||||
private _moveEndLineSelectionShrink: boolean;
|
||||
|
||||
constructor(selection: Selection, isMovingDown: boolean, autoIndent: boolean) {
|
||||
constructor(selection: Selection, isMovingDown: boolean, autoIndent: EditorAutoIndentStrategy) {
|
||||
this._selection = selection;
|
||||
this._isMovingDown = isMovingDown;
|
||||
this._autoIndent = autoIndent;
|
||||
@@ -117,7 +118,7 @@ export class MoveLinesCommand implements ICommand {
|
||||
return model.getLineContent(lineNumber);
|
||||
}
|
||||
};
|
||||
let indentOfMovingLine = LanguageConfigurationRegistry.getGoodIndentForLine(virtualModel, model.getLanguageIdAtPosition(
|
||||
let indentOfMovingLine = LanguageConfigurationRegistry.getGoodIndentForLine(this._autoIndent, virtualModel, model.getLanguageIdAtPosition(
|
||||
movingLineNumber, 1), s.startLineNumber, indentConverter);
|
||||
if (indentOfMovingLine !== null) {
|
||||
let oldIndentation = strings.getLeadingWhitespace(model.getLineContent(movingLineNumber));
|
||||
@@ -152,7 +153,7 @@ export class MoveLinesCommand implements ICommand {
|
||||
}
|
||||
};
|
||||
|
||||
let newIndentatOfMovingBlock = LanguageConfigurationRegistry.getGoodIndentForLine(virtualModel, model.getLanguageIdAtPosition(
|
||||
let newIndentatOfMovingBlock = LanguageConfigurationRegistry.getGoodIndentForLine(this._autoIndent, virtualModel, model.getLanguageIdAtPosition(
|
||||
movingLineNumber, 1), s.startLineNumber + 1, indentConverter);
|
||||
|
||||
if (newIndentatOfMovingBlock !== null) {
|
||||
@@ -197,7 +198,7 @@ export class MoveLinesCommand implements ICommand {
|
||||
}
|
||||
} else {
|
||||
// it doesn't match any onEnter rule, let's check indentation rules then.
|
||||
let indentOfFirstLine = LanguageConfigurationRegistry.getGoodIndentForLine(virtualModel, model.getLanguageIdAtPosition(s.startLineNumber, 1), movingLineNumber, indentConverter);
|
||||
let indentOfFirstLine = LanguageConfigurationRegistry.getGoodIndentForLine(this._autoIndent, virtualModel, model.getLanguageIdAtPosition(s.startLineNumber, 1), movingLineNumber, indentConverter);
|
||||
if (indentOfFirstLine !== null) {
|
||||
// adjust the indentation of the moving block
|
||||
let oldIndent = strings.getLeadingWhitespace(model.getLineContent(s.startLineNumber));
|
||||
@@ -251,20 +252,19 @@ export class MoveLinesCommand implements ICommand {
|
||||
}
|
||||
|
||||
let maxColumn = model.getLineMaxColumn(validPrecedingLine);
|
||||
let enter = LanguageConfigurationRegistry.getEnterAction(model, new Range(validPrecedingLine, maxColumn, validPrecedingLine, maxColumn));
|
||||
let enter = LanguageConfigurationRegistry.getEnterAction(this._autoIndent, model, new Range(validPrecedingLine, maxColumn, validPrecedingLine, maxColumn));
|
||||
|
||||
if (enter) {
|
||||
let enterPrefix = enter.indentation;
|
||||
let enterAction = enter.enterAction;
|
||||
|
||||
if (enterAction.indentAction === IndentAction.None) {
|
||||
enterPrefix = enter.indentation + enterAction.appendText;
|
||||
} else if (enterAction.indentAction === IndentAction.Indent) {
|
||||
enterPrefix = enter.indentation + enterAction.appendText;
|
||||
} else if (enterAction.indentAction === IndentAction.IndentOutdent) {
|
||||
if (enter.indentAction === IndentAction.None) {
|
||||
enterPrefix = enter.indentation + enter.appendText;
|
||||
} else if (enter.indentAction === IndentAction.Indent) {
|
||||
enterPrefix = enter.indentation + enter.appendText;
|
||||
} else if (enter.indentAction === IndentAction.IndentOutdent) {
|
||||
enterPrefix = enter.indentation;
|
||||
} else if (enterAction.indentAction === IndentAction.Outdent) {
|
||||
enterPrefix = indentConverter.unshiftIndent(enter.indentation) + enterAction.appendText;
|
||||
} else if (enter.indentAction === IndentAction.Outdent) {
|
||||
enterPrefix = indentConverter.unshiftIndent(enter.indentation) + enter.appendText;
|
||||
}
|
||||
let movingLineText = model.getLineContent(line);
|
||||
if (this.trimLeft(movingLineText).indexOf(this.trimLeft(enterPrefix)) >= 0) {
|
||||
@@ -288,7 +288,7 @@ export class MoveLinesCommand implements ICommand {
|
||||
}
|
||||
|
||||
private shouldAutoIndent(model: ITextModel, selection: Selection) {
|
||||
if (!this._autoIndent) {
|
||||
if (this._autoIndent < EditorAutoIndentStrategy.Full) {
|
||||
return false;
|
||||
}
|
||||
// if it's not easy to tokenize, we stop auto indent.
|
||||
|
||||
@@ -11,6 +11,14 @@ import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/mod
|
||||
|
||||
export class SortLinesCommand implements editorCommon.ICommand {
|
||||
|
||||
private static _COLLATOR: Intl.Collator | null = null;
|
||||
public static getCollator(): Intl.Collator {
|
||||
if (!SortLinesCommand._COLLATOR) {
|
||||
SortLinesCommand._COLLATOR = new Intl.Collator();
|
||||
}
|
||||
return SortLinesCommand._COLLATOR;
|
||||
}
|
||||
|
||||
private readonly selection: Selection;
|
||||
private readonly descending: boolean;
|
||||
private selectionId: string | null;
|
||||
@@ -76,9 +84,7 @@ function getSortData(model: ITextModel, selection: Selection, descending: boolea
|
||||
}
|
||||
|
||||
let sorted = linesToSort.slice(0);
|
||||
sorted.sort((a, b) => {
|
||||
return a.toLowerCase().localeCompare(b.toLowerCase());
|
||||
});
|
||||
sorted.sort(SortLinesCommand.getCollator().compare);
|
||||
|
||||
// If descending, reverse the order.
|
||||
if (descending === true) {
|
||||
|
||||
@@ -9,21 +9,22 @@ import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageCo
|
||||
import { MoveLinesCommand } from 'vs/editor/contrib/linesOperations/moveLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
import { MockMode } from 'vs/editor/test/common/mocks/mockMode';
|
||||
import { EditorAutoIndentStrategy } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
function testMoveLinesDownCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
testCommand(lines, null, selection, (sel) => new MoveLinesCommand(sel, true, false), expectedLines, expectedSelection);
|
||||
testCommand(lines, null, selection, (sel) => new MoveLinesCommand(sel, true, EditorAutoIndentStrategy.Advanced), expectedLines, expectedSelection);
|
||||
}
|
||||
|
||||
function testMoveLinesUpCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
testCommand(lines, null, selection, (sel) => new MoveLinesCommand(sel, false, false), expectedLines, expectedSelection);
|
||||
testCommand(lines, null, selection, (sel) => new MoveLinesCommand(sel, false, EditorAutoIndentStrategy.Advanced), expectedLines, expectedSelection);
|
||||
}
|
||||
|
||||
function testMoveLinesDownWithIndentCommand(languageId: LanguageIdentifier, lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
testCommand(lines, languageId, selection, (sel) => new MoveLinesCommand(sel, true, true), expectedLines, expectedSelection);
|
||||
testCommand(lines, languageId, selection, (sel) => new MoveLinesCommand(sel, true, EditorAutoIndentStrategy.Full), expectedLines, expectedSelection);
|
||||
}
|
||||
|
||||
function testMoveLinesUpWithIndentCommand(languageId: LanguageIdentifier, lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
testCommand(lines, languageId, selection, (sel) => new MoveLinesCommand(sel, false, true), expectedLines, expectedSelection);
|
||||
testCommand(lines, languageId, selection, (sel) => new MoveLinesCommand(sel, false, EditorAutoIndentStrategy.Full), expectedLines, expectedSelection);
|
||||
}
|
||||
|
||||
suite('Editor Contrib - Move Lines Command', () => {
|
||||
|
||||
Reference in New Issue
Block a user