mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-21 04:20:11 -04:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -7,9 +7,9 @@ import * as nls from 'vs/nls';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { ICommonCodeEditor, IEditorContribution, IIdentifiedSingleEditOperation, ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel, EndOfLineSequence } from 'vs/editor/common/editorCommon';
|
||||
import { IEditorContribution, IIdentifiedSingleEditOperation, ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { editorAction, ServicesAccessor, IActionOptions, EditorAction, commonEditorContribution } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { registerEditorAction, ServicesAccessor, IActionOptions, EditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
@@ -20,6 +20,8 @@ import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageCo
|
||||
import { ShiftCommand } from 'vs/editor/common/commands/shiftCommand';
|
||||
import { TextEdit, StandardTokenType } from 'vs/editor/common/modes';
|
||||
import * as IndentUtil from './indentUtils';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IndentConsts } from 'vs/editor/common/modes/supports/indentRules';
|
||||
|
||||
export function shiftIndent(tabSize: number, indentation: string, count?: number): string {
|
||||
count = count || 1;
|
||||
@@ -147,9 +149,8 @@ export function getReindentEditOperations(model: ITokenizedModel, startLineNumbe
|
||||
return indentEdits;
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class IndentationToSpacesAction extends EditorAction {
|
||||
public static ID = 'editor.action.indentationToSpaces';
|
||||
public static readonly ID = 'editor.action.indentationToSpaces';
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
@@ -160,7 +161,7 @@ export class IndentationToSpacesAction extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
let model = editor.getModel();
|
||||
if (!model) {
|
||||
return;
|
||||
@@ -178,9 +179,8 @@ export class IndentationToSpacesAction extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class IndentationToTabsAction extends EditorAction {
|
||||
public static ID = 'editor.action.indentationToTabs';
|
||||
public static readonly ID = 'editor.action.indentationToTabs';
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
@@ -191,7 +191,7 @@ export class IndentationToTabsAction extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
let model = editor.getModel();
|
||||
if (!model) {
|
||||
return;
|
||||
@@ -215,7 +215,7 @@ export class ChangeIndentationSizeAction extends EditorAction {
|
||||
super(opts);
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): TPromise<void> {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): TPromise<void> {
|
||||
const quickOpenService = accessor.get(IQuickOpenService);
|
||||
const modelService = accessor.get(IModelService);
|
||||
|
||||
@@ -248,10 +248,9 @@ export class ChangeIndentationSizeAction extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class IndentUsingTabs extends ChangeIndentationSizeAction {
|
||||
|
||||
public static ID = 'editor.action.indentUsingTabs';
|
||||
public static readonly ID = 'editor.action.indentUsingTabs';
|
||||
|
||||
constructor() {
|
||||
super(false, {
|
||||
@@ -263,10 +262,9 @@ export class IndentUsingTabs extends ChangeIndentationSizeAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class IndentUsingSpaces extends ChangeIndentationSizeAction {
|
||||
|
||||
public static ID = 'editor.action.indentUsingSpaces';
|
||||
public static readonly ID = 'editor.action.indentUsingSpaces';
|
||||
|
||||
constructor() {
|
||||
super(true, {
|
||||
@@ -278,10 +276,9 @@ export class IndentUsingSpaces extends ChangeIndentationSizeAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class DetectIndentation extends EditorAction {
|
||||
|
||||
public static ID = 'editor.action.detectIndentation';
|
||||
public static readonly ID = 'editor.action.detectIndentation';
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
@@ -292,7 +289,7 @@ export class DetectIndentation extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
const modelService = accessor.get(IModelService);
|
||||
|
||||
let model = editor.getModel();
|
||||
@@ -305,7 +302,6 @@ export class DetectIndentation extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class ReindentLinesAction extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -316,7 +312,7 @@ export class ReindentLinesAction extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
let model = editor.getModel();
|
||||
if (!model) {
|
||||
return;
|
||||
@@ -333,7 +329,6 @@ export class ReindentLinesAction extends EditorAction {
|
||||
export class AutoIndentOnPasteCommand implements ICommand {
|
||||
|
||||
private _edits: TextEdit[];
|
||||
private _newEol: EndOfLineSequence;
|
||||
|
||||
private _initialSelection: Selection;
|
||||
private _selectionId: string;
|
||||
@@ -341,12 +336,8 @@ export class AutoIndentOnPasteCommand implements ICommand {
|
||||
constructor(edits: TextEdit[], initialSelection: Selection) {
|
||||
this._initialSelection = initialSelection;
|
||||
this._edits = [];
|
||||
this._newEol = undefined;
|
||||
|
||||
for (let edit of edits) {
|
||||
if (typeof edit.eol === 'number') {
|
||||
this._newEol = edit.eol;
|
||||
}
|
||||
if (edit.range && typeof edit.text === 'string') {
|
||||
this._edits.push(edit);
|
||||
}
|
||||
@@ -381,15 +372,14 @@ export class AutoIndentOnPasteCommand implements ICommand {
|
||||
}
|
||||
}
|
||||
|
||||
@commonEditorContribution
|
||||
export class AutoIndentOnPaste implements IEditorContribution {
|
||||
private static ID = 'editor.contrib.autoIndentOnPaste';
|
||||
private static readonly ID = 'editor.contrib.autoIndentOnPaste';
|
||||
|
||||
private editor: ICommonCodeEditor;
|
||||
private editor: ICodeEditor;
|
||||
private callOnDispose: IDisposable[];
|
||||
private callOnModel: IDisposable[];
|
||||
|
||||
constructor(editor: ICommonCodeEditor) {
|
||||
constructor(editor: ICodeEditor) {
|
||||
this.editor = editor;
|
||||
this.callOnDispose = [];
|
||||
this.callOnModel = [];
|
||||
@@ -483,10 +473,31 @@ export class AutoIndentOnPaste implements IEditorContribution {
|
||||
text: newIndent
|
||||
});
|
||||
firstLineText = newIndent + firstLineText.substr(oldIndentation.length);
|
||||
} else {
|
||||
let indentMetadata = LanguageConfigurationRegistry.getIndentMetadata(model, startLineNumber);
|
||||
|
||||
if (indentMetadata === 0 || indentMetadata === IndentConsts.UNINDENT_MASK) {
|
||||
// we paste content into a line where only contains whitespaces
|
||||
// after pasting, the indentation of the first line is already correct
|
||||
// the first line doesn't match any indentation rule
|
||||
// then no-op.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const firstLineNumber = startLineNumber;
|
||||
|
||||
// ignore empty or ignored lines
|
||||
while (startLineNumber < range.endLineNumber) {
|
||||
if (!/\S/.test(model.getLineContent(startLineNumber + 1))) {
|
||||
startLineNumber++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (startLineNumber !== range.endLineNumber) {
|
||||
let virtualModel = {
|
||||
getLineTokens: (lineNumber: number) => {
|
||||
@@ -499,7 +510,7 @@ export class AutoIndentOnPaste implements IEditorContribution {
|
||||
return model.getLanguageIdAtPosition(lineNumber, column);
|
||||
},
|
||||
getLineContent: (lineNumber: number) => {
|
||||
if (lineNumber === startLineNumber) {
|
||||
if (lineNumber === firstLineNumber) {
|
||||
return firstLineText;
|
||||
} else {
|
||||
return model.getLineContent(lineNumber);
|
||||
@@ -620,3 +631,11 @@ export class IndentationToTabsCommand implements ICommand {
|
||||
return helper.getTrackedSelection(this.selectionId);
|
||||
}
|
||||
}
|
||||
|
||||
registerEditorContribution(AutoIndentOnPaste);
|
||||
registerEditorAction(IndentationToSpacesAction);
|
||||
registerEditorAction(IndentationToTabsAction);
|
||||
registerEditorAction(IndentUsingTabs);
|
||||
registerEditorAction(IndentUsingSpaces);
|
||||
registerEditorAction(DetectIndentation);
|
||||
registerEditorAction(ReindentLinesAction);
|
||||
@@ -4,8 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { IndentationToSpacesCommand, IndentationToTabsCommand } from 'vs/editor/contrib/indentation/common/indentation';
|
||||
import { testCommand } from 'vs/editor/test/common/commands/commandTestUtils';
|
||||
import { IndentationToSpacesCommand, IndentationToTabsCommand } from 'vs/editor/contrib/indentation/indentation';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
|
||||
function testIndentationToSpacesCommand(lines: string[], selection: Selection, tabSize: number, expectedLines: string[], expectedSelection: Selection): void {
|
||||
testCommand(lines, null, selection, (sel) => new IndentationToSpacesCommand(sel, tabSize), expectedLines, expectedSelection);
|
||||
|
||||
Reference in New Issue
Block a user