Path: blob/main/src/vs/editor/contrib/indentation/test/browser/indentation.test.ts
5311 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import assert from 'assert';6import { DisposableStore, IDisposable } from '../../../../../base/common/lifecycle.js';7import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';8import { ILanguageConfigurationService } from '../../../../common/languages/languageConfigurationRegistry.js';9import { createTextModel } from '../../../../test/common/testTextModel.js';10import { TestInstantiationService } from '../../../../../platform/instantiation/test/common/instantiationServiceMock.js';11import { Range } from '../../../../common/core/range.js';12import { Selection } from '../../../../common/core/selection.js';13import { MetadataConsts, StandardTokenType } from '../../../../common/encodedTokenAttributes.js';14import { EncodedTokenizationResult, IState, ITokenizationSupport, TokenizationRegistry } from '../../../../common/languages.js';15import { ILanguageService } from '../../../../common/languages/language.js';16import { NullState } from '../../../../common/languages/nullTokenize.js';17import { AutoIndentOnPaste, IndentationToSpacesCommand, IndentationToTabsCommand } from '../../browser/indentation.js';18import { withTestCodeEditor } from '../../../../test/browser/testCodeEditor.js';19import { testCommand } from '../../../../test/browser/testCommand.js';20import { goIndentationRules, htmlIndentationRules, javascriptIndentationRules, latexIndentationRules, luaIndentationRules, phpIndentationRules, rubyIndentationRules, vbIndentationRules } from '../../../../test/common/modes/supports/indentationRules.js';21import { cppOnEnterRules, htmlOnEnterRules, javascriptOnEnterRules, phpOnEnterRules, vbOnEnterRules } from '../../../../test/common/modes/supports/onEnterRules.js';22import { TypeOperations } from '../../../../common/cursor/cursorTypeOperations.js';23import { cppBracketRules, goBracketRules, htmlBracketRules, latexBracketRules, luaBracketRules, phpBracketRules, rubyBracketRules, typescriptBracketRules, vbBracketRules } from '../../../../test/common/modes/supports/bracketRules.js';24import { javascriptAutoClosingPairsRules, latexAutoClosingPairsRules } from '../../../../test/common/modes/supports/autoClosingPairsRules.js';25import { LanguageService } from '../../../../common/services/languageService.js';26import { ServiceCollection } from '../../../../../platform/instantiation/common/serviceCollection.js';27import { TestLanguageConfigurationService } from '../../../../test/common/modes/testLanguageConfigurationService.js';2829export enum Language {30TypeScript = 'ts-test',31Ruby = 'ruby-test',32PHP = 'php-test',33Go = 'go-test',34CPP = 'cpp-test',35HTML = 'html-test',36VB = 'vb-test',37Latex = 'latex-test',38Lua = 'lua-test'39}4041function testIndentationToSpacesCommand(lines: string[], selection: Selection, tabSize: number, expectedLines: string[], expectedSelection: Selection): void {42testCommand(lines, null, selection, (accessor, sel) => new IndentationToSpacesCommand(sel, tabSize), expectedLines, expectedSelection);43}4445function testIndentationToTabsCommand(lines: string[], selection: Selection, tabSize: number, expectedLines: string[], expectedSelection: Selection): void {46testCommand(lines, null, selection, (accessor, sel) => new IndentationToTabsCommand(sel, tabSize), expectedLines, expectedSelection);47}4849export function registerLanguage(languageService: ILanguageService, language: Language): IDisposable {50return languageService.registerLanguage({ id: language });51}5253export function registerLanguageConfiguration(languageConfigurationService: ILanguageConfigurationService, language: Language): IDisposable {54switch (language) {55case Language.TypeScript:56return languageConfigurationService.register(language, {57brackets: typescriptBracketRules,58comments: {59lineComment: '//',60blockComment: ['/*', '*/']61},62autoClosingPairs: javascriptAutoClosingPairsRules,63indentationRules: javascriptIndentationRules,64onEnterRules: javascriptOnEnterRules65});66case Language.Ruby:67return languageConfigurationService.register(language, {68brackets: rubyBracketRules,69indentationRules: rubyIndentationRules,70});71case Language.PHP:72return languageConfigurationService.register(language, {73brackets: phpBracketRules,74indentationRules: phpIndentationRules,75onEnterRules: phpOnEnterRules76});77case Language.Go:78return languageConfigurationService.register(language, {79brackets: goBracketRules,80indentationRules: goIndentationRules81});82case Language.CPP:83return languageConfigurationService.register(language, {84brackets: cppBracketRules,85onEnterRules: cppOnEnterRules86});87case Language.HTML:88return languageConfigurationService.register(language, {89brackets: htmlBracketRules,90indentationRules: htmlIndentationRules,91onEnterRules: htmlOnEnterRules92});93case Language.VB:94return languageConfigurationService.register(language, {95brackets: vbBracketRules,96indentationRules: vbIndentationRules,97onEnterRules: vbOnEnterRules,98});99case Language.Latex:100return languageConfigurationService.register(language, {101brackets: latexBracketRules,102autoClosingPairs: latexAutoClosingPairsRules,103indentationRules: latexIndentationRules104});105case Language.Lua:106return languageConfigurationService.register(language, {107brackets: luaBracketRules,108indentationRules: luaIndentationRules109});110}111}112113export interface StandardTokenTypeData {114startIndex: number;115standardTokenType: StandardTokenType;116}117118export function registerTokenizationSupport(instantiationService: TestInstantiationService, tokens: StandardTokenTypeData[][], languageId: Language): IDisposable {119let lineIndex = 0;120const languageService = instantiationService.get(ILanguageService);121const tokenizationSupport: ITokenizationSupport = {122getInitialState: () => NullState,123tokenize: undefined!,124tokenizeEncoded: (line: string, hasEOL: boolean, state: IState): EncodedTokenizationResult => {125const tokensOnLine = tokens[lineIndex++];126const encodedLanguageId = languageService.languageIdCodec.encodeLanguageId(languageId);127const result = new Uint32Array(2 * tokensOnLine.length);128for (let i = 0; i < tokensOnLine.length; i++) {129result[2 * i] = tokensOnLine[i].startIndex;130result[2 * i + 1] =131(132(encodedLanguageId << MetadataConsts.LANGUAGEID_OFFSET)133| (tokensOnLine[i].standardTokenType << MetadataConsts.TOKEN_TYPE_OFFSET)134);135}136return new EncodedTokenizationResult(result, [], state);137}138};139return TokenizationRegistry.register(languageId, tokenizationSupport);140}141142suite('Change Indentation to Spaces - TypeScript/Javascript', () => {143144ensureNoDisposablesAreLeakedInTestSuite();145146test('single tabs only at start of line', function () {147testIndentationToSpacesCommand(148[149'first',150'second line',151'third line',152'\tfourth line',153'\tfifth'154],155new Selection(2, 3, 2, 3),1564,157[158'first',159'second line',160'third line',161' fourth line',162' fifth'163],164new Selection(2, 3, 2, 3)165);166});167168test('multiple tabs at start of line', function () {169testIndentationToSpacesCommand(170[171'\t\tfirst',172'\tsecond line',173'\t\t\t third line',174'fourth line',175'fifth'176],177new Selection(1, 5, 1, 5),1783,179[180' first',181' second line',182' third line',183'fourth line',184'fifth'185],186new Selection(1, 9, 1, 9)187);188});189190test('multiple tabs', function () {191testIndentationToSpacesCommand(192[193'\t\tfirst\t',194'\tsecond \t line \t',195'\t\t\t third line',196' \tfourth line',197'fifth'198],199new Selection(1, 5, 1, 5),2002,201[202' first\t',203' second \t line \t',204' third line',205' fourth line',206'fifth'207],208new Selection(1, 7, 1, 7)209);210});211212test('empty lines', function () {213testIndentationToSpacesCommand(214[215'\t\t\t',216'\t',217'\t\t'218],219new Selection(1, 4, 1, 4),2202,221[222' ',223' ',224' '225],226new Selection(1, 4, 1, 4)227);228});229});230231suite('Change Indentation to Tabs - TypeScript/Javascript', () => {232233ensureNoDisposablesAreLeakedInTestSuite();234235test('spaces only at start of line', function () {236testIndentationToTabsCommand(237[238' first',239'second line',240' third line',241'fourth line',242'fifth'243],244new Selection(2, 3, 2, 3),2454,246[247'\tfirst',248'second line',249'\tthird line',250'fourth line',251'fifth'252],253new Selection(2, 3, 2, 3)254);255});256257test('multiple spaces at start of line', function () {258testIndentationToTabsCommand(259[260'first',261' second line',262' third line',263'fourth line',264' fifth'265],266new Selection(1, 5, 1, 5),2673,268[269'first',270'\tsecond line',271'\t\t\t third line',272'fourth line',273'\t fifth'274],275new Selection(1, 5, 1, 5)276);277});278279test('multiple spaces', function () {280testIndentationToTabsCommand(281[282' first ',283' second line \t',284' third line',285' fourth line',286'fifth'287],288new Selection(1, 8, 1, 8),2892,290[291'\t\t\tfirst ',292'\tsecond line \t',293'\t\t\t third line',294'\t fourth line',295'fifth'296],297new Selection(1, 5, 1, 5)298);299});300301test('issue #45996', function () {302testIndentationToSpacesCommand(303[304'\tabc',305],306new Selection(1, 3, 1, 3),3074,308[309' abc',310],311new Selection(1, 6, 1, 6)312);313});314});315316suite('Indent With Tab - TypeScript/JavaScript', () => {317318const languageId = Language.TypeScript;319let disposables: DisposableStore;320let serviceCollection: ServiceCollection;321322setup(() => {323disposables = new DisposableStore();324const languageService = new LanguageService();325const languageConfigurationService = new TestLanguageConfigurationService();326disposables.add(languageService);327disposables.add(languageConfigurationService);328disposables.add(registerLanguage(languageService, languageId));329disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));330serviceCollection = new ServiceCollection(331[ILanguageService, languageService],332[ILanguageConfigurationService, languageConfigurationService]333);334});335336teardown(() => {337disposables.dispose();338});339340ensureNoDisposablesAreLeakedInTestSuite();341342test('temp issue because there should be at least one passing test in a suite', () => {343assert.ok(true);344});345346test.skip('issue #63388: perserve correct indentation on tab 1', () => {347348// https://github.com/microsoft/vscode/issues/63388349350const model = createTextModel([351'/*',352' * Comment',353' * /',354].join('\n'), languageId, {});355disposables.add(model);356357withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {358editor.setSelection(new Selection(1, 1, 3, 5));359editor.executeCommands('editor.action.indentLines', TypeOperations.indent(viewModel.cursorConfig, editor.getModel(), editor.getSelections()));360assert.strictEqual(model.getValue(), [361' /*',362' * Comment',363' * /',364].join('\n'));365});366});367368test.skip('issue #63388: perserve correct indentation on tab 2', () => {369370// https://github.com/microsoft/vscode/issues/63388371372const model = createTextModel([373'switch (something) {',374' case 1:',375' whatever();',376' break;',377'}',378].join('\n'), languageId, {});379disposables.add(model);380381withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {382editor.setSelection(new Selection(1, 1, 5, 2));383editor.executeCommands('editor.action.indentLines', TypeOperations.indent(viewModel.cursorConfig, editor.getModel(), editor.getSelections()));384assert.strictEqual(model.getValue(), [385' switch (something) {',386' case 1:',387' whatever();',388' break;',389' }',390].join('\n'));391});392});393});394395suite('Auto Indent On Paste - TypeScript/JavaScript', () => {396397const languageId = Language.TypeScript;398let disposables: DisposableStore;399let serviceCollection: ServiceCollection;400401setup(() => {402disposables = new DisposableStore();403const languageService = new LanguageService();404const languageConfigurationService = new TestLanguageConfigurationService();405disposables.add(languageService);406disposables.add(languageConfigurationService);407disposables.add(registerLanguage(languageService, languageId));408disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));409serviceCollection = new ServiceCollection(410[ILanguageService, languageService],411[ILanguageConfigurationService, languageConfigurationService]412);413});414415teardown(() => {416disposables.dispose();417});418419ensureNoDisposablesAreLeakedInTestSuite();420421test('issue #119225: Do not add extra leading space when pasting JSDoc', () => {422423const model = createTextModel('', languageId, {});424disposables.add(model);425426withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {427const pasteText = [428'/**',429' * JSDoc',430' */',431'function a() {}'432].join('\n');433const tokens: StandardTokenTypeData[][] = [434[435{ startIndex: 0, standardTokenType: StandardTokenType.Comment },436{ startIndex: 3, standardTokenType: StandardTokenType.Comment },437],438[439{ startIndex: 0, standardTokenType: StandardTokenType.Comment },440{ startIndex: 2, standardTokenType: StandardTokenType.Comment },441{ startIndex: 8, standardTokenType: StandardTokenType.Comment },442],443[444{ startIndex: 0, standardTokenType: StandardTokenType.Comment },445{ startIndex: 1, standardTokenType: StandardTokenType.Comment },446{ startIndex: 3, standardTokenType: StandardTokenType.Other },447],448[449{ startIndex: 0, standardTokenType: StandardTokenType.Other },450{ startIndex: 8, standardTokenType: StandardTokenType.Other },451{ startIndex: 9, standardTokenType: StandardTokenType.Other },452{ startIndex: 10, standardTokenType: StandardTokenType.Other },453{ startIndex: 11, standardTokenType: StandardTokenType.Other },454{ startIndex: 12, standardTokenType: StandardTokenType.Other },455{ startIndex: 13, standardTokenType: StandardTokenType.Other },456{ startIndex: 14, standardTokenType: StandardTokenType.Other },457{ startIndex: 15, standardTokenType: StandardTokenType.Other },458]459];460disposables.add(registerTokenizationSupport(instantiationService, tokens, languageId));461const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);462viewModel.paste(pasteText, true, undefined, 'keyboard');463autoIndentOnPasteController.trigger(new Range(1, 1, 4, 16));464assert.strictEqual(model.getValue(), pasteText);465});466});467468test('issue #167299: Blank line removes indent', () => {469470const model = createTextModel('', languageId, {});471disposables.add(model);472473withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {474475// no need for tokenization because there are no comments476const pasteText = [477'',478'export type IncludeReference =',479' | BaseReference',480' | SelfReference',481' | RelativeReference;',482'',483'export const enum IncludeReferenceKind {',484' Base,',485' Self,',486' RelativeReference,',487'}'488].join('\n');489490const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);491viewModel.paste(pasteText, true, undefined, 'keyboard');492autoIndentOnPasteController.trigger(new Range(1, 1, 11, 2));493assert.strictEqual(model.getValue(), pasteText);494});495});496497test('issue #29803: do not indent when pasting text with only one line', () => {498499// https://github.com/microsoft/vscode/issues/29803500501const model = createTextModel([502'const linkHandler = new Class(a, b, c,',503' d)'504].join('\n'), languageId, {});505disposables.add(model);506507withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {508editor.setSelection(new Selection(2, 6, 2, 6));509const text = ', null';510viewModel.paste(text, true, undefined, 'keyboard');511const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);512autoIndentOnPasteController.trigger(new Range(2, 6, 2, 11));513assert.strictEqual(model.getValue(), [514'const linkHandler = new Class(a, b, c,',515' d, null)'516].join('\n'));517});518});519520test('issue #29753: incorrect indentation after comment', () => {521522// https://github.com/microsoft/vscode/issues/29753523524const model = createTextModel([525'class A {',526' /**',527' * used only for debug purposes.',528' */',529' private _codeInfo: KeyMapping[];',530'}',531].join('\n'), languageId, {});532disposables.add(model);533534withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {535editor.setSelection(new Selection(5, 24, 5, 34));536const text = 'IMacLinuxKeyMapping';537viewModel.paste(text, true, undefined, 'keyboard');538const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);539autoIndentOnPasteController.trigger(new Range(5, 24, 5, 43));540assert.strictEqual(model.getValue(), [541'class A {',542' /**',543' * used only for debug purposes.',544' */',545' private _codeInfo: IMacLinuxKeyMapping[];',546'}',547].join('\n'));548});549});550551test('issue #29753: incorrect indentation of header comment', () => {552553// https://github.com/microsoft/vscode/issues/29753554555const model = createTextModel('', languageId, {});556disposables.add(model);557558withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {559const text = [560'/*----------------',561' * Copyright (c) ',562' * Licensed under ...',563' *-----------------*/',564].join('\n');565viewModel.paste(text, true, undefined, 'keyboard');566const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);567autoIndentOnPasteController.trigger(new Range(1, 1, 4, 22));568assert.strictEqual(model.getValue(), text);569});570});571572test('issue #209859: do not do change indentation when pasted inside of a string', () => {573574// issue: https://github.com/microsoft/vscode/issues/209859575// issue: https://github.com/microsoft/vscode/issues/209418576577const initialText = [578'const foo = "some text',579' which is strangely',580' indented"'581].join('\n');582const model = createTextModel(initialText, languageId, {});583disposables.add(model);584585withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {586const tokens: StandardTokenTypeData[][] = [587[588{ startIndex: 0, standardTokenType: StandardTokenType.Other },589{ startIndex: 12, standardTokenType: StandardTokenType.String },590],591[592{ startIndex: 0, standardTokenType: StandardTokenType.String },593],594[595{ startIndex: 0, standardTokenType: StandardTokenType.String },596]597];598disposables.add(registerTokenizationSupport(instantiationService, tokens, languageId));599600editor.setSelection(new Selection(2, 10, 2, 15));601viewModel.paste('which', true, undefined, 'keyboard');602const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);603autoIndentOnPasteController.trigger(new Range(2, 1, 2, 28));604assert.strictEqual(model.getValue(), initialText);605});606});607608// Failing tests found in issues...609610test.skip('issue #181065: Incorrect paste of object within comment', () => {611612// https://github.com/microsoft/vscode/issues/181065613614const model = createTextModel('', languageId, {});615disposables.add(model);616617withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {618const text = [619'/**',620' * @typedef {',621' * }',622' */'623].join('\n');624const tokens: StandardTokenTypeData[][] = [625[626{ startIndex: 0, standardTokenType: StandardTokenType.Comment },627{ startIndex: 3, standardTokenType: StandardTokenType.Comment },628],629[630{ startIndex: 0, standardTokenType: StandardTokenType.Comment },631{ startIndex: 2, standardTokenType: StandardTokenType.Comment },632{ startIndex: 3, standardTokenType: StandardTokenType.Comment },633{ startIndex: 11, standardTokenType: StandardTokenType.Comment },634{ startIndex: 12, standardTokenType: StandardTokenType.Other },635{ startIndex: 13, standardTokenType: StandardTokenType.Other },636],637[638{ startIndex: 0, standardTokenType: StandardTokenType.Comment },639{ startIndex: 2, standardTokenType: StandardTokenType.Other },640{ startIndex: 3, standardTokenType: StandardTokenType.Other },641{ startIndex: 4, standardTokenType: StandardTokenType.Other },642],643[644{ startIndex: 0, standardTokenType: StandardTokenType.Comment },645{ startIndex: 1, standardTokenType: StandardTokenType.Comment },646{ startIndex: 3, standardTokenType: StandardTokenType.Other },647]648];649disposables.add(registerTokenizationSupport(instantiationService, tokens, languageId));650const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);651viewModel.paste(text, true, undefined, 'keyboard');652autoIndentOnPasteController.trigger(new Range(1, 1, 4, 4));653assert.strictEqual(model.getValue(), text);654});655});656657test.skip('issue #86301: preserve cursor at inserted indentation level', () => {658659// https://github.com/microsoft/vscode/issues/86301660661const model = createTextModel([662'() => {',663'',664'}',665].join('\n'), languageId, {});666disposables.add(model);667668withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {669editor.setSelection(new Selection(2, 1, 2, 1));670const text = [671'() => {',672'',673'}',674''675].join('\n');676const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);677viewModel.paste(text, true, undefined, 'keyboard');678autoIndentOnPasteController.trigger(new Range(2, 1, 5, 1));679680// notes:681// why is line 3 not indented to the same level as line 2?682// looks like the indentation is inserted correctly at line 5, but the cursor does not appear at the maximum indentation level?683assert.strictEqual(model.getValue(), [684'() => {',685' () => {',686' ', // <- should also be indented687' }',688' ', // <- cursor should be at the end of the indentation689'}',690].join('\n'));691692const selection = viewModel.getSelection();693assert.deepStrictEqual(selection, new Selection(5, 5, 5, 5));694});695});696697test.skip('issue #85781: indent line with extra white space', () => {698699// https://github.com/microsoft/vscode/issues/85781700// note: still to determine whether this is a bug or not701702const model = createTextModel([703'() => {',704' console.log("a");',705'}',706].join('\n'), languageId, {});707disposables.add(model);708709withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {710editor.setSelection(new Selection(2, 5, 2, 5));711const text = [712'() => {',713' console.log("b")',714'}',715' '716].join('\n');717const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);718viewModel.paste(text, true, undefined, 'keyboard');719// todo@aiday-mar, make sure range is correct, and make test work as in real life720autoIndentOnPasteController.trigger(new Range(2, 5, 5, 6));721assert.strictEqual(model.getValue(), [722'() => {',723' () => {',724' console.log("b")',725' }',726' console.log("a");',727'}',728].join('\n'));729});730});731732test.skip('issue #29589: incorrect indentation of closing brace on paste', () => {733734// https://github.com/microsoft/vscode/issues/29589735736const model = createTextModel('', languageId, {});737disposables.add(model);738739withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {740editor.setSelection(new Selection(2, 5, 2, 5));741const text = [742'function makeSub(a,b) {',743'subsent = sent.substring(a,b);',744'return subsent;',745'}',746].join('\n');747const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);748viewModel.paste(text, true, undefined, 'keyboard');749// todo@aiday-mar, make sure range is correct, and make test work as in real life750autoIndentOnPasteController.trigger(new Range(1, 1, 4, 2));751assert.strictEqual(model.getValue(), [752'function makeSub(a,b) {',753'subsent = sent.substring(a,b);',754'return subsent;',755'}',756].join('\n'));757});758});759760test.skip('issue #201420: incorrect indentation when first line is comment', () => {761762// https://github.com/microsoft/vscode/issues/201420763764const model = createTextModel([765'function bar() {',766'',767'}',768].join('\n'), languageId, {});769disposables.add(model);770771withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {772const tokens: StandardTokenTypeData[][] = [773[774{ startIndex: 0, standardTokenType: StandardTokenType.Other },775{ startIndex: 8, standardTokenType: StandardTokenType.Other },776{ startIndex: 9, standardTokenType: StandardTokenType.Other },777{ startIndex: 12, standardTokenType: StandardTokenType.Other },778{ startIndex: 13, standardTokenType: StandardTokenType.Other },779{ startIndex: 14, standardTokenType: StandardTokenType.Other },780{ startIndex: 15, standardTokenType: StandardTokenType.Other },781{ startIndex: 16, standardTokenType: StandardTokenType.Other }782],783[784{ startIndex: 0, standardTokenType: StandardTokenType.Comment },785{ startIndex: 2, standardTokenType: StandardTokenType.Comment },786{ startIndex: 3, standardTokenType: StandardTokenType.Comment },787{ startIndex: 10, standardTokenType: StandardTokenType.Comment }788],789[790{ startIndex: 0, standardTokenType: StandardTokenType.Other },791{ startIndex: 5, standardTokenType: StandardTokenType.Other },792{ startIndex: 6, standardTokenType: StandardTokenType.Other },793{ startIndex: 9, standardTokenType: StandardTokenType.Other },794{ startIndex: 10, standardTokenType: StandardTokenType.Other },795{ startIndex: 11, standardTokenType: StandardTokenType.Other },796{ startIndex: 12, standardTokenType: StandardTokenType.Other },797{ startIndex: 14, standardTokenType: StandardTokenType.Other }],798[799{ startIndex: 0, standardTokenType: StandardTokenType.Other },800{ startIndex: 1, standardTokenType: StandardTokenType.Other }]801];802disposables.add(registerTokenizationSupport(instantiationService, tokens, languageId));803804editor.setSelection(new Selection(2, 1, 2, 1));805const text = [806'// comment',807'const foo = 42',808].join('\n');809const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);810viewModel.paste(text, true, undefined, 'keyboard');811autoIndentOnPasteController.trigger(new Range(2, 1, 3, 15));812assert.strictEqual(model.getValue(), [813'function bar() {',814' // comment',815' const foo = 42',816'}',817].join('\n'));818});819});820});821822suite('Auto Indent On Type - TypeScript/JavaScript', () => {823824const languageId = Language.TypeScript;825let disposables: DisposableStore;826let serviceCollection: ServiceCollection;827828setup(() => {829disposables = new DisposableStore();830const languageService = new LanguageService();831const languageConfigurationService = new TestLanguageConfigurationService();832disposables.add(languageService);833disposables.add(languageConfigurationService);834disposables.add(registerLanguage(languageService, languageId));835disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));836serviceCollection = new ServiceCollection(837[ILanguageService, languageService],838[ILanguageConfigurationService, languageConfigurationService]839);840});841842teardown(() => {843disposables.dispose();844});845846ensureNoDisposablesAreLeakedInTestSuite();847848// Failing tests from issues...849850test('issue #208215: indent after arrow function', () => {851852// https://github.com/microsoft/vscode/issues/208215853854const model = createTextModel('', languageId, {});855disposables.add(model);856857withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {858viewModel.type('const add1 = (n) =>');859viewModel.type('\n', 'keyboard');860assert.strictEqual(model.getValue(), [861'const add1 = (n) =>',862' ',863].join('\n'));864});865});866867test('issue #208215: indent after arrow function 2', () => {868869// https://github.com/microsoft/vscode/issues/208215870871const model = createTextModel([872'const array = [1, 2, 3, 4, 5];',873'array.map(',874' v =>',875].join('\n'), languageId, {});876disposables.add(model);877878withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {879editor.setSelection(new Selection(3, 9, 3, 9));880viewModel.type('\n', 'keyboard');881assert.strictEqual(model.getValue(), [882'const array = [1, 2, 3, 4, 5];',883'array.map(',884' v =>',885' '886].join('\n'));887});888});889890test('issue #116843: indent after arrow function', () => {891892// https://github.com/microsoft/vscode/issues/116843893894const model = createTextModel('', languageId, {});895disposables.add(model);896897withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {898viewModel.type([899'const add1 = (n) =>',900' n + 1;',901].join('\n'));902viewModel.type('\n', 'keyboard');903assert.strictEqual(model.getValue(), [904'const add1 = (n) =>',905' n + 1;',906'',907].join('\n'));908});909});910911test('issue #29755: do not add indentation on enter if indentation is already valid', () => {912913//https://github.com/microsoft/vscode/issues/29755914915const model = createTextModel([916'function f() {',917' const one = 1;',918' const two = 2;',919'}',920].join('\n'), languageId, {});921disposables.add(model);922923withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {924editor.setSelection(new Selection(3, 1, 3, 1));925viewModel.type('\n', 'keyboard');926assert.strictEqual(model.getValue(), [927'function f() {',928' const one = 1;',929'',930' const two = 2;',931'}',932].join('\n'));933});934});935936test('issue #36090', () => {937938// https://github.com/microsoft/vscode/issues/36090939940const model = createTextModel([941'class ItemCtrl {',942' getPropertiesByItemId(id) {',943' return this.fetchItem(id)',944' .then(item => {',945' return this.getPropertiesOfItem(item);',946' });',947' }',948'}',949].join('\n'), languageId, {});950disposables.add(model);951952withTestCodeEditor(model, { autoIndent: 'advanced', serviceCollection }, (editor, viewModel) => {953editor.setSelection(new Selection(7, 6, 7, 6));954viewModel.type('\n', 'keyboard');955assert.strictEqual(model.getValue(),956[957'class ItemCtrl {',958' getPropertiesByItemId(id) {',959' return this.fetchItem(id)',960' .then(item => {',961' return this.getPropertiesOfItem(item);',962' });',963' }',964' ',965'}',966].join('\n')967);968assert.deepStrictEqual(editor.getSelection(), new Selection(8, 5, 8, 5));969});970});971972test('issue #115304: indent block comment onEnter', () => {973974// https://github.com/microsoft/vscode/issues/115304975976const model = createTextModel([977'/** */',978'function f() {}',979].join('\n'), languageId, {});980disposables.add(model);981982withTestCodeEditor(model, { autoIndent: 'advanced', serviceCollection }, (editor, viewModel) => {983editor.setSelection(new Selection(1, 4, 1, 4));984viewModel.type('\n', 'keyboard');985assert.strictEqual(model.getValue(),986[987'/**',988' * ',989' */',990'function f() {}',991].join('\n')992);993assert.deepStrictEqual(editor.getSelection(), new Selection(2, 4, 2, 4));994});995});996997test('issue #43244: indent when lambda arrow function is detected, outdent when end is reached', () => {998999// https://github.com/microsoft/vscode/issues/4324410001001const model = createTextModel([1002'const array = [1, 2, 3, 4, 5];',1003'array.map(_)'1004].join('\n'), languageId, {});1005disposables.add(model);10061007withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1008editor.setSelection(new Selection(2, 12, 2, 12));1009viewModel.type('\n', 'keyboard');1010assert.strictEqual(model.getValue(), [1011'const array = [1, 2, 3, 4, 5];',1012'array.map(_',1013' ',1014')'1015].join('\n'));1016});1017});10181019test('issue #43244: incorrect indentation after if/for/while without braces', () => {10201021// https://github.com/microsoft/vscode/issues/4324410221023const model = createTextModel([1024'function f() {',1025' if (condition)',1026'}'1027].join('\n'), languageId, {});1028disposables.add(model);10291030withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1031editor.setSelection(new Selection(2, 19, 2, 19));1032viewModel.type('\n', 'keyboard');1033assert.strictEqual(model.getValue(), [1034'function f() {',1035' if (condition)',1036' ',1037'}',1038].join('\n'));10391040viewModel.type('return;');1041viewModel.type('\n', 'keyboard');1042assert.strictEqual(model.getValue(), [1043'function f() {',1044' if (condition)',1045' return;',1046' ',1047'}',1048].join('\n'));1049});1050});10511052test('issue #208232: incorrect indentation inside of comments', () => {10531054// https://github.com/microsoft/vscode/issues/20823210551056const model = createTextModel([1057'/**',1058'indentation done for {',1059'*/'1060].join('\n'), languageId, {});1061disposables.add(model);10621063withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {1064const tokens: StandardTokenTypeData[][] = [1065[{ startIndex: 0, standardTokenType: StandardTokenType.Comment }],1066[{ startIndex: 0, standardTokenType: StandardTokenType.Comment }],1067[{ startIndex: 0, standardTokenType: StandardTokenType.Comment }]1068];1069disposables.add(registerTokenizationSupport(instantiationService, tokens, languageId));1070editor.setSelection(new Selection(2, 23, 2, 23));1071viewModel.type('\n', 'keyboard');1072assert.strictEqual(model.getValue(), [1073'/**',1074'indentation done for {',1075'',1076'*/'1077].join('\n'));1078});1079});10801081test('issue #209802: allman style braces in JavaScript', () => {10821083// https://github.com/microsoft/vscode/issues/20980210841085const model = createTextModel([1086'if (/*condition*/)',1087].join('\n'), languageId, {});1088disposables.add(model);10891090withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1091editor.setSelection(new Selection(1, 19, 1, 19));1092viewModel.type('\n', 'keyboard');1093assert.strictEqual(model.getValue(), [1094'if (/*condition*/)',1095' '1096].join('\n'));1097viewModel.type('{', 'keyboard');1098assert.strictEqual(model.getValue(), [1099'if (/*condition*/)',1100'{}'1101].join('\n'));1102editor.setSelection(new Selection(2, 2, 2, 2));1103viewModel.type('\n', 'keyboard');1104assert.strictEqual(model.getValue(), [1105'if (/*condition*/)',1106'{',1107' ',1108'}'1109].join('\n'));1110});1111});11121113// Failing tests...11141115test.skip('issue #43244: indent after equal sign is detected', () => {11161117// https://github.com/microsoft/vscode/issues/432441118// issue: Should indent after an equal sign is detected followed by whitespace characters.1119// This should be outdented when a semi-colon is detected indicating the end of the assignment.11201121// TODO: requires exploring indent/outdent pairs instead11221123const model = createTextModel([1124'const array ='1125].join('\n'), languageId, {});1126disposables.add(model);11271128withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1129editor.setSelection(new Selection(1, 14, 1, 14));1130viewModel.type('\n', 'keyboard');1131assert.strictEqual(model.getValue(), [1132'const array =',1133' '1134].join('\n'));1135});1136});11371138test.skip('issue #43244: indent after dot detected after object/array signifying a method call', () => {11391140// https://github.com/microsoft/vscode/issues/432441141// issue: When a dot is written, we should detect that this is a method call and indent accordingly11421143// TODO: requires exploring indent/outdent pairs instead11441145const model = createTextModel([1146'const array = [1, 2, 3];',1147'array.'1148].join('\n'), languageId, {});1149disposables.add(model);11501151withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1152editor.setSelection(new Selection(2, 7, 2, 7));1153viewModel.type('\n', 'keyboard');1154assert.strictEqual(model.getValue(), [1155'const array = [1, 2, 3];',1156'array.',1157' '1158].join('\n'));1159});1160});11611162test.skip('issue #43244: indent after dot detected on a subsequent line after object/array signifying a method call', () => {11631164// https://github.com/microsoft/vscode/issues/432441165// issue: When a dot is written, we should detect that this is a method call and indent accordingly11661167// TODO: requires exploring indent/outdent pairs instead11681169const model = createTextModel([1170'const array = [1, 2, 3]',1171].join('\n'), languageId, {});1172disposables.add(model);11731174withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1175editor.setSelection(new Selection(2, 7, 2, 7));1176viewModel.type('\n', 'keyboard');1177viewModel.type('.');1178assert.strictEqual(model.getValue(), [1179'const array = [1, 2, 3]',1180' .'1181].join('\n'));1182});1183});11841185test.skip('issue #43244: keep indentation when methods called on object/array', () => {11861187// https://github.com/microsoft/vscode/issues/432441188// Currently passes, but should pass with all the tests above too11891190// TODO: requires exploring indent/outdent pairs instead11911192const model = createTextModel([1193'const array = [1, 2, 3]',1194' .filter(() => true)'1195].join('\n'), languageId, {});1196disposables.add(model);11971198withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1199editor.setSelection(new Selection(2, 24, 2, 24));1200viewModel.type('\n', 'keyboard');1201assert.strictEqual(model.getValue(), [1202'const array = [1, 2, 3]',1203' .filter(() => true)',1204' '1205].join('\n'));1206});1207});12081209test.skip('issue #43244: keep indentation when chained methods called on object/array', () => {12101211// https://github.com/microsoft/vscode/issues/432441212// When the call chain is not finished yet, and we type a dot, we do not want to change the indentation12131214// TODO: requires exploring indent/outdent pairs instead12151216const model = createTextModel([1217'const array = [1, 2, 3]',1218' .filter(() => true)',1219' '1220].join('\n'), languageId, {});1221disposables.add(model);12221223withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1224editor.setSelection(new Selection(3, 5, 3, 5));1225viewModel.type('.');1226assert.strictEqual(model.getValue(), [1227'const array = [1, 2, 3]',1228' .filter(() => true)',1229' .' // here we don't want to increase the indentation because we have chained methods1230].join('\n'));1231});1232});12331234test.skip('issue #43244: outdent when a semi-color is detected indicating the end of the assignment', () => {12351236// https://github.com/microsoft/vscode/issues/4324412371238// TODO: requires exploring indent/outdent pairs instead12391240const model = createTextModel([1241'const array = [1, 2, 3]',1242' .filter(() => true);'1243].join('\n'), languageId, {});1244disposables.add(model);12451246withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1247editor.setSelection(new Selection(2, 25, 2, 25));1248viewModel.type('\n', 'keyboard');1249assert.strictEqual(model.getValue(), [1250'const array = [1, 2, 3]',1251' .filter(() => true);',1252''1253].join('\n'));1254});1255});125612571258test.skip('issue #40115: keep indentation when added', () => {12591260// https://github.com/microsoft/vscode/issues/4011512611262const model = createTextModel('function foo() {}', languageId, {});1263disposables.add(model);12641265withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1266editor.setSelection(new Selection(1, 17, 1, 17));1267viewModel.type('\n', 'keyboard');1268assert.strictEqual(model.getValue(), [1269'function foo() {',1270' ',1271'}',1272].join('\n'));1273editor.setSelection(new Selection(2, 5, 2, 5));1274viewModel.type('\n', 'keyboard');1275assert.strictEqual(model.getValue(), [1276'function foo() {',1277' ',1278' ',1279'}',1280].join('\n'));1281});1282});12831284test.skip('issue #193875: incorrect indentation on enter', () => {12851286// https://github.com/microsoft/vscode/issues/19387512871288const model = createTextModel([1289'{',1290' for(;;)',1291' for(;;) {}',1292'}',1293].join('\n'), languageId, {});1294disposables.add(model);12951296withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1297editor.setSelection(new Selection(3, 14, 3, 14));1298viewModel.type('\n', 'keyboard');1299assert.strictEqual(model.getValue(), [1300'{',1301' for(;;)',1302' for(;;) {',1303' ',1304' }',1305'}',1306].join('\n'));1307});1308});13091310test.skip('issue #67678: indent on typing curly brace', () => {13111312// https://github.com/microsoft/vscode/issues/6767813131314const model = createTextModel([1315'if (true) {',1316'console.log("a")',1317'console.log("b")',1318'',1319].join('\n'), languageId, {});1320disposables.add(model);13211322withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1323editor.setSelection(new Selection(4, 1, 4, 1));1324viewModel.type('}', 'keyboard');1325assert.strictEqual(model.getValue(), [1326'if (true) {',1327' console.log("a")',1328' console.log("b")',1329'}',1330].join('\n'));1331});1332});13331334test.skip('issue #46401: outdent when encountering bracket on line - allman style indentation', () => {13351336// https://github.com/microsoft/vscode/issues/4640113371338const model = createTextModel([1339'if (true)',1340' ',1341].join('\n'), languageId, {});1342disposables.add(model);13431344withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1345editor.setSelection(new Selection(2, 5, 2, 5));1346viewModel.type('{}', 'keyboard');1347assert.strictEqual(model.getValue(), [1348'if (true)',1349'{}',1350].join('\n'));1351editor.setSelection(new Selection(2, 2, 2, 2));1352viewModel.type('\n', 'keyboard');1353assert.strictEqual(model.getValue(), [1354'if (true)',1355'{',1356' ',1357'}'1358].join('\n'));1359});1360});13611362test.skip('issue #125261: typing closing brace does not keep the current indentation', () => {13631364// https://github.com/microsoft/vscode/issues/12526113651366const model = createTextModel([1367'foo {',1368' ',1369].join('\n'), languageId, {});1370disposables.add(model);13711372withTestCodeEditor(model, { autoIndent: 'keep', serviceCollection }, (editor, viewModel) => {1373editor.setSelection(new Selection(2, 5, 2, 5));1374viewModel.type('}', 'keyboard');1375assert.strictEqual(model.getValue(), [1376'foo {',1377'}',1378].join('\n'));1379});1380});1381});13821383suite('Auto Indent On Type - Ruby', () => {13841385const languageId = Language.Ruby;1386let disposables: DisposableStore;1387let serviceCollection: ServiceCollection;13881389setup(() => {1390disposables = new DisposableStore();1391const languageService = new LanguageService();1392const languageConfigurationService = new TestLanguageConfigurationService();1393disposables.add(languageService);1394disposables.add(languageConfigurationService);1395disposables.add(registerLanguage(languageService, languageId));1396disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));1397serviceCollection = new ServiceCollection(1398[ILanguageService, languageService],1399[ILanguageConfigurationService, languageConfigurationService]1400);1401});14021403teardown(() => {1404disposables.dispose();1405});14061407ensureNoDisposablesAreLeakedInTestSuite();14081409test('issue #198350: in or when incorrectly match non keywords for Ruby', () => {14101411// https://github.com/microsoft/vscode/issues/19835014121413const model = createTextModel('', languageId, {});1414disposables.add(model);14151416withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1417viewModel.type('def foo\n i');1418viewModel.type('n', 'keyboard');1419assert.strictEqual(model.getValue(), 'def foo\n in');1420viewModel.type(' ', 'keyboard');1421assert.strictEqual(model.getValue(), 'def foo\nin ');14221423viewModel.model.setValue('');1424viewModel.type(' # in');1425assert.strictEqual(model.getValue(), ' # in');1426viewModel.type(' ', 'keyboard');1427assert.strictEqual(model.getValue(), ' # in ');1428});1429});14301431// Failing tests...14321433test.skip('issue #199846: in or when incorrectly match non keywords for Ruby', () => {14341435// https://github.com/microsoft/vscode/issues/1998461436// explanation: happening because the # is detected probably as a comment14371438const model = createTextModel('', languageId, {});1439disposables.add(model);14401441withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1442viewModel.type(`method('#foo') do`);1443viewModel.type('\n', 'keyboard');1444assert.strictEqual(model.getValue(), [1445`method('#foo') do`,1446' '1447].join('\n'));1448});1449});1450});14511452suite('Auto Indent On Type - PHP', () => {14531454const languageId = Language.PHP;1455let disposables: DisposableStore;1456let serviceCollection: ServiceCollection;14571458setup(() => {1459disposables = new DisposableStore();1460const languageService = new LanguageService();1461const languageConfigurationService = new TestLanguageConfigurationService();1462disposables.add(languageService);1463disposables.add(languageConfigurationService);1464disposables.add(registerLanguage(languageService, languageId));1465disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));1466serviceCollection = new ServiceCollection(1467[ILanguageService, languageService],1468[ILanguageConfigurationService, languageConfigurationService]1469);1470});14711472teardown(() => {1473disposables.dispose();1474});14751476ensureNoDisposablesAreLeakedInTestSuite();14771478test('issue #199050: should not indent after { detected in a string', () => {14791480// https://github.com/microsoft/vscode/issues/19905014811482const model = createTextModel(`preg_replace('{');`, languageId, {});1483disposables.add(model);14841485withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {1486const tokens: StandardTokenTypeData[][] = [1487[1488{ startIndex: 0, standardTokenType: StandardTokenType.Other },1489{ startIndex: 13, standardTokenType: StandardTokenType.String },1490{ startIndex: 16, standardTokenType: StandardTokenType.Other },1491]1492];1493disposables.add(registerTokenizationSupport(instantiationService, tokens, languageId));1494editor.setSelection(new Selection(1, 54, 1, 54));1495viewModel.type('\n', 'keyboard');1496assert.strictEqual(model.getValue(), [1497`preg_replace('{');`,1498''1499].join('\n'));1500});1501});1502});15031504suite('Auto Indent On Paste - Go', () => {15051506const languageId = Language.Go;1507let disposables: DisposableStore;1508let serviceCollection: ServiceCollection;15091510setup(() => {1511disposables = new DisposableStore();1512const languageService = new LanguageService();1513const languageConfigurationService = new TestLanguageConfigurationService();1514disposables.add(languageService);1515disposables.add(languageConfigurationService);1516disposables.add(registerLanguage(languageService, languageId));1517disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));1518serviceCollection = new ServiceCollection(1519[ILanguageService, languageService],1520[ILanguageConfigurationService, languageConfigurationService]1521);1522});15231524teardown(() => {1525disposables.dispose();1526});15271528ensureNoDisposablesAreLeakedInTestSuite();15291530test('temp issue because there should be at least one passing test in a suite', () => {1531assert.ok(true);1532});15331534test.skip('issue #199050: should not indent after { detected in a string', () => {15351536// https://github.com/microsoft/vscode/issues/19905015371538const model = createTextModel([1539'var s = `',1540'quick brown',1541'fox',1542'`',1543].join('\n'), languageId, {});1544disposables.add(model);15451546withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1547editor.setSelection(new Selection(3, 1, 3, 1));1548const text = ' ';1549const autoIndentOnPasteController = editor.registerAndInstantiateContribution(AutoIndentOnPaste.ID, AutoIndentOnPaste);1550viewModel.paste(text, true, undefined, 'keyboard');1551autoIndentOnPasteController.trigger(new Range(3, 1, 3, 3));1552assert.strictEqual(model.getValue(), [1553'var s = `',1554'quick brown',1555' fox',1556'`',1557].join('\n'));1558});1559});1560});15611562suite('Auto Indent On Type - CPP', () => {15631564const languageId = Language.CPP;1565let disposables: DisposableStore;1566let serviceCollection: ServiceCollection;15671568setup(() => {1569disposables = new DisposableStore();1570const languageService = new LanguageService();1571const languageConfigurationService = new TestLanguageConfigurationService();1572disposables.add(languageService);1573disposables.add(languageConfigurationService);1574disposables.add(registerLanguage(languageService, languageId));1575disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));1576serviceCollection = new ServiceCollection(1577[ILanguageService, languageService],1578[ILanguageConfigurationService, languageConfigurationService]1579);1580});15811582teardown(() => {1583disposables.dispose();1584});15851586ensureNoDisposablesAreLeakedInTestSuite();15871588test('temp issue because there should be at least one passing test in a suite', () => {1589assert.ok(true);1590});15911592test.skip('issue #178334: incorrect outdent of } when signature spans multiple lines', () => {15931594// https://github.com/microsoft/vscode/issues/17833415951596const model = createTextModel([1597'int WINAPI WinMain(bool instance,',1598' int nshowcmd) {}',1599].join('\n'), languageId, {});1600disposables.add(model);16011602withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1603editor.setSelection(new Selection(2, 20, 2, 20));1604viewModel.type('\n', 'keyboard');1605assert.strictEqual(model.getValue(), [1606'int WINAPI WinMain(bool instance,',1607' int nshowcmd) {',1608' ',1609'}'1610].join('\n'));1611});1612});16131614test.skip('issue #118929: incorrect indent when // follows curly brace', () => {16151616// https://github.com/microsoft/vscode/issues/11892916171618const model = createTextModel([1619'if (true) { // jaja',1620'}',1621].join('\n'), languageId, {});1622disposables.add(model);16231624withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1625editor.setSelection(new Selection(1, 20, 1, 20));1626viewModel.type('\n', 'keyboard');1627assert.strictEqual(model.getValue(), [1628'if (true) { // jaja',1629' ',1630'}',1631].join('\n'));1632});1633});16341635test.skip('issue #111265: auto indentation set to "none" still changes the indentation', () => {16361637// https://github.com/microsoft/vscode/issues/11126516381639const model = createTextModel([1640'int func() {',1641' ',1642].join('\n'), languageId, {});1643disposables.add(model);16441645withTestCodeEditor(model, { autoIndent: 'none', serviceCollection }, (editor, viewModel) => {1646editor.setSelection(new Selection(2, 3, 2, 3));1647viewModel.type('}', 'keyboard');1648assert.strictEqual(model.getValue(), [1649'int func() {',1650' }',1651].join('\n'));1652});1653});16541655});16561657suite('Auto Indent On Type - HTML', () => {16581659const languageId = Language.HTML;1660let disposables: DisposableStore;1661let serviceCollection: ServiceCollection;16621663setup(() => {1664disposables = new DisposableStore();1665const languageService = new LanguageService();1666const languageConfigurationService = new TestLanguageConfigurationService();1667disposables.add(languageService);1668disposables.add(languageConfigurationService);1669disposables.add(registerLanguage(languageService, languageId));1670disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));1671serviceCollection = new ServiceCollection(1672[ILanguageService, languageService],1673[ILanguageConfigurationService, languageConfigurationService]1674);1675});16761677teardown(() => {1678disposables.dispose();1679});16801681ensureNoDisposablesAreLeakedInTestSuite();16821683test('temp issue because there should be at least one passing test in a suite', () => {1684assert.ok(true);1685});16861687test.skip('issue #61510: incorrect indentation after // in html file', () => {16881689// https://github.com/microsoft/vscode/issues/17833416901691const model = createTextModel([1692'<pre>',1693' foo //I press <Enter> at the end of this line',1694'</pre>',1695].join('\n'), languageId, {});1696disposables.add(model);16971698withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1699editor.setSelection(new Selection(2, 48, 2, 48));1700viewModel.type('\n', 'keyboard');1701assert.strictEqual(model.getValue(), [1702'<pre>',1703' foo //I press <Enter> at the end of this line',1704' ',1705'</pre>',1706].join('\n'));1707});1708});1709});17101711suite('Auto Indent On Type - Visual Basic', () => {17121713const languageId = Language.VB;1714let disposables: DisposableStore;1715let serviceCollection: ServiceCollection;17161717setup(() => {1718disposables = new DisposableStore();1719const languageService = new LanguageService();1720const languageConfigurationService = new TestLanguageConfigurationService();1721disposables.add(languageService);1722disposables.add(languageConfigurationService);1723disposables.add(registerLanguage(languageService, languageId));1724disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));1725serviceCollection = new ServiceCollection(1726[ILanguageService, languageService],1727[ILanguageConfigurationService, languageConfigurationService]1728);1729});17301731teardown(() => {1732disposables.dispose();1733});17341735ensureNoDisposablesAreLeakedInTestSuite();17361737test('temp issue because there should be at least one passing test in a suite', () => {1738assert.ok(true);1739});17401741test('issue #118932: no indentation in visual basic files', () => {17421743// https://github.com/microsoft/vscode/issues/11893217441745const model = createTextModel([1746'If True Then',1747' Some code',1748' End I',1749].join('\n'), languageId, {});1750disposables.add(model);17511752withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel, instantiationService) => {1753editor.setSelection(new Selection(3, 10, 3, 10));1754viewModel.type('f', 'keyboard');1755assert.strictEqual(model.getValue(), [1756'If True Then',1757' Some code',1758'End If',1759].join('\n'));1760});1761});17621763test('issue #118932: indent after Module declaration', () => {17641765// https://github.com/microsoft/vscode/issues/11893217661767const model = createTextModel('', languageId, {});1768disposables.add(model);17691770withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1771viewModel.type('Module Test');1772viewModel.type('\n', 'keyboard');1773assert.strictEqual(model.getValue(), [1774'Module Test',1775' ',1776].join('\n'));1777});1778});17791780test('issue #118932: indent after Sub declaration', () => {17811782// https://github.com/microsoft/vscode/issues/11893217831784const model = createTextModel([1785'Module Test',1786' ',1787].join('\n'), languageId, {});1788disposables.add(model);17891790withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1791editor.setSelection(new Selection(2, 5, 2, 5));1792viewModel.type('Sub Main()');1793viewModel.type('\n', 'keyboard');1794assert.strictEqual(model.getValue(), [1795'Module Test',1796' Sub Main()',1797' ',1798].join('\n'));1799});1800});18011802test('issue #118932: dedent on End Sub', () => {18031804// https://github.com/microsoft/vscode/issues/11893218051806const model = createTextModel([1807'Module Test',1808' Sub Main()',1809' Console.WriteLine("Hello")',1810' End Su',1811].join('\n'), languageId, {});1812disposables.add(model);18131814withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1815editor.setSelection(new Selection(4, 15, 4, 15));1816viewModel.type('b', 'keyboard');1817assert.strictEqual(model.getValue(), [1818'Module Test',1819' Sub Main()',1820' Console.WriteLine("Hello")',1821' End Sub',1822].join('\n'));1823});1824});18251826test('issue #118932: dedent on End Module', () => {18271828// https://github.com/microsoft/vscode/issues/1189321829// When End Module is typed right after Module (no nested blocks), it dedents correctly18301831const model = createTextModel([1832'Module Test',1833' Private x As Integer',1834' End Modul',1835].join('\n'), languageId, {});1836disposables.add(model);18371838withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1839editor.setSelection(new Selection(3, 14, 3, 14));1840viewModel.type('e', 'keyboard');1841assert.strictEqual(model.getValue(), [1842'Module Test',1843' Private x As Integer',1844'End Module',1845].join('\n'));1846});1847});18481849test('issue #118932: indent after Function declaration', () => {18501851// https://github.com/microsoft/vscode/issues/11893218521853const model = createTextModel([1854'Module Test',1855' ',1856].join('\n'), languageId, {});1857disposables.add(model);18581859withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1860editor.setSelection(new Selection(2, 5, 2, 5));1861viewModel.type('Function Add(a As Integer, b As Integer) As Integer');1862viewModel.type('\n', 'keyboard');1863assert.strictEqual(model.getValue(), [1864'Module Test',1865' Function Add(a As Integer, b As Integer) As Integer',1866' ',1867].join('\n'));1868});1869});18701871test('issue #118932: dedent on End Function', () => {18721873// https://github.com/microsoft/vscode/issues/11893218741875const model = createTextModel([1876'Module Test',1877' Function Add(a, b)',1878' Return a + b',1879' End Functio',1880].join('\n'), languageId, {});1881disposables.add(model);18821883withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1884editor.setSelection(new Selection(4, 20, 4, 20));1885viewModel.type('n', 'keyboard');1886assert.strictEqual(model.getValue(), [1887'Module Test',1888' Function Add(a, b)',1889' Return a + b',1890' End Function',1891].join('\n'));1892});1893});18941895test('issue #118932: indent after If Then', () => {18961897// https://github.com/microsoft/vscode/issues/11893218981899const model = createTextModel([1900'Sub Test()',1901' ',1902].join('\n'), languageId, {});1903disposables.add(model);19041905withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1906editor.setSelection(new Selection(2, 5, 2, 5));1907viewModel.type('If x > 0 Then');1908viewModel.type('\n', 'keyboard');1909assert.strictEqual(model.getValue(), [1910'Sub Test()',1911' If x > 0 Then',1912' ',1913].join('\n'));1914});1915});19161917test('issue #118932: indent after ElseIf Then', () => {19181919// https://github.com/microsoft/vscode/issues/11893219201921const model = createTextModel([1922'Sub Test()',1923' If x > 0 Then',1924' DoSomething()',1925' ElseIf x < 0 Then',1926].join('\n'), languageId, {});1927disposables.add(model);19281929withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1930editor.setSelection(new Selection(4, 22, 4, 22));1931viewModel.type('\n', 'keyboard');1932assert.strictEqual(model.getValue(), [1933'Sub Test()',1934' If x > 0 Then',1935' DoSomething()',1936' ElseIf x < 0 Then',1937' ',1938].join('\n'));1939});1940});19411942test('issue #118932: dedent and indent on Else', () => {19431944// https://github.com/microsoft/vscode/issues/11893219451946const model = createTextModel([1947'Sub Test()',1948' If x > 0 Then',1949' DoSomething()',1950' Els',1951].join('\n'), languageId, {});1952disposables.add(model);19531954withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1955editor.setSelection(new Selection(4, 12, 4, 12));1956viewModel.type('e', 'keyboard');1957assert.strictEqual(model.getValue(), [1958'Sub Test()',1959' If x > 0 Then',1960' DoSomething()',1961' Else',1962].join('\n'));1963});1964});19651966test('issue #118932: indent after While', () => {19671968// https://github.com/microsoft/vscode/issues/11893219691970const model = createTextModel([1971'Sub Test()',1972' ',1973].join('\n'), languageId, {});1974disposables.add(model);19751976withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {1977editor.setSelection(new Selection(2, 5, 2, 5));1978viewModel.type('While x > 0');1979viewModel.type('\n', 'keyboard');1980assert.strictEqual(model.getValue(), [1981'Sub Test()',1982' While x > 0',1983' ',1984].join('\n'));1985});1986});19871988test('issue #118932: dedent on End While', () => {19891990// https://github.com/microsoft/vscode/issues/11893219911992const model = createTextModel([1993'Sub Test()',1994' While x > 0',1995' x = x - 1',1996' End Whil',1997].join('\n'), languageId, {});1998disposables.add(model);19992000withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2001editor.setSelection(new Selection(4, 17, 4, 17));2002viewModel.type('e', 'keyboard');2003assert.strictEqual(model.getValue(), [2004'Sub Test()',2005' While x > 0',2006' x = x - 1',2007' End While',2008].join('\n'));2009});2010});20112012test('issue #118932: indent after For', () => {20132014// https://github.com/microsoft/vscode/issues/11893220152016const model = createTextModel([2017'Sub Test()',2018' ',2019].join('\n'), languageId, {});2020disposables.add(model);20212022withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2023editor.setSelection(new Selection(2, 5, 2, 5));2024viewModel.type('For i = 1 To 10');2025viewModel.type('\n', 'keyboard');2026assert.strictEqual(model.getValue(), [2027'Sub Test()',2028' For i = 1 To 10',2029' ',2030].join('\n'));2031});2032});20332034test('issue #118932: dedent on Next', () => {20352036// https://github.com/microsoft/vscode/issues/11893220372038const model = createTextModel([2039'Sub Test()',2040' For i = 1 To 10',2041' DoSomething(i)',2042' Nex',2043].join('\n'), languageId, {});2044disposables.add(model);20452046withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2047editor.setSelection(new Selection(4, 12, 4, 12));2048viewModel.type('t', 'keyboard');2049assert.strictEqual(model.getValue(), [2050'Sub Test()',2051' For i = 1 To 10',2052' DoSomething(i)',2053' Next',2054].join('\n'));2055});2056});20572058test('issue #118932: indent after Do', () => {20592060// https://github.com/microsoft/vscode/issues/11893220612062const model = createTextModel([2063'Sub Test()',2064' ',2065].join('\n'), languageId, {});2066disposables.add(model);20672068withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2069editor.setSelection(new Selection(2, 5, 2, 5));2070viewModel.type('Do');2071viewModel.type('\n', 'keyboard');2072assert.strictEqual(model.getValue(), [2073'Sub Test()',2074' Do',2075' ',2076].join('\n'));2077});2078});20792080test('issue #118932: dedent on Loop', () => {20812082// https://github.com/microsoft/vscode/issues/11893220832084const model = createTextModel([2085'Sub Test()',2086' Do',2087' x = x + 1',2088' Loo',2089].join('\n'), languageId, {});2090disposables.add(model);20912092withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2093editor.setSelection(new Selection(4, 12, 4, 12));2094viewModel.type('p', 'keyboard');2095assert.strictEqual(model.getValue(), [2096'Sub Test()',2097' Do',2098' x = x + 1',2099' Loop',2100].join('\n'));2101});2102});21032104test('issue #118932: indent after Select Case', () => {21052106// https://github.com/microsoft/vscode/issues/11893221072108const model = createTextModel([2109'Sub Test()',2110' ',2111].join('\n'), languageId, {});2112disposables.add(model);21132114withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2115editor.setSelection(new Selection(2, 5, 2, 5));2116viewModel.type('Select Case x');2117viewModel.type('\n', 'keyboard');2118assert.strictEqual(model.getValue(), [2119'Sub Test()',2120' Select Case x',2121' ',2122].join('\n'));2123});2124});21252126test('issue #118932: dedent on End Select', () => {21272128// https://github.com/microsoft/vscode/issues/1189322129// When End Select is typed, it dedents to match Select Case level21302131const model = createTextModel([2132'Sub Test()',2133' Select Case x',2134' End Selec',2135].join('\n'), languageId, {});2136disposables.add(model);21372138withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2139editor.setSelection(new Selection(3, 18, 3, 18));2140viewModel.type('t', 'keyboard');2141assert.strictEqual(model.getValue(), [2142'Sub Test()',2143' Select Case x',2144' End Select',2145].join('\n'));2146});2147});21482149test('issue #118932: indent after Try', () => {21502151// https://github.com/microsoft/vscode/issues/11893221522153const model = createTextModel([2154'Sub Test()',2155' ',2156].join('\n'), languageId, {});2157disposables.add(model);21582159withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2160editor.setSelection(new Selection(2, 5, 2, 5));2161viewModel.type('Try');2162viewModel.type('\n', 'keyboard');2163assert.strictEqual(model.getValue(), [2164'Sub Test()',2165' Try',2166' ',2167].join('\n'));2168});2169});21702171test('issue #118932: dedent and indent on Catch', () => {21722173// https://github.com/microsoft/vscode/issues/11893221742175const model = createTextModel([2176'Sub Test()',2177' Try',2178' DoSomething()',2179' Catc',2180].join('\n'), languageId, {});2181disposables.add(model);21822183withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2184editor.setSelection(new Selection(4, 13, 4, 13));2185viewModel.type('h', 'keyboard');2186assert.strictEqual(model.getValue(), [2187'Sub Test()',2188' Try',2189' DoSomething()',2190' Catch',2191].join('\n'));2192});2193});21942195test('issue #118932: dedent and indent on Finally', () => {21962197// https://github.com/microsoft/vscode/issues/11893221982199const model = createTextModel([2200'Sub Test()',2201' Try',2202' DoSomething()',2203' Catch',2204' HandleError()',2205' Finall',2206].join('\n'), languageId, {});2207disposables.add(model);22082209withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2210editor.setSelection(new Selection(6, 15, 6, 15));2211viewModel.type('y', 'keyboard');2212assert.strictEqual(model.getValue(), [2213'Sub Test()',2214' Try',2215' DoSomething()',2216' Catch',2217' HandleError()',2218' Finally',2219].join('\n'));2220});2221});22222223test('issue #118932: dedent on End Try', () => {22242225// https://github.com/microsoft/vscode/issues/11893222262227const model = createTextModel([2228'Sub Test()',2229' Try',2230' DoSomething()',2231' Catch',2232' HandleError()',2233' Finally',2234' Cleanup()',2235' End Tr',2236].join('\n'), languageId, {});2237disposables.add(model);22382239withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2240editor.setSelection(new Selection(8, 15, 8, 15));2241viewModel.type('y', 'keyboard');2242assert.strictEqual(model.getValue(), [2243'Sub Test()',2244' Try',2245' DoSomething()',2246' Catch',2247' HandleError()',2248' Finally',2249' Cleanup()',2250' End Try',2251].join('\n'));2252});2253});22542255test('issue #118932: indent after Class', () => {22562257// https://github.com/microsoft/vscode/issues/11893222582259const model = createTextModel('', languageId, {});2260disposables.add(model);22612262withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2263viewModel.type('Class MyClass');2264viewModel.type('\n', 'keyboard');2265assert.strictEqual(model.getValue(), [2266'Class MyClass',2267' ',2268].join('\n'));2269});2270});22712272test('issue #118932: dedent on End Class', () => {22732274// https://github.com/microsoft/vscode/issues/11893222752276const model = createTextModel([2277'Class MyClass',2278' Private x As Integer',2279' End Clas',2280].join('\n'), languageId, {});2281disposables.add(model);22822283withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2284editor.setSelection(new Selection(3, 14, 3, 14));2285viewModel.type('s', 'keyboard');2286assert.strictEqual(model.getValue(), [2287'Class MyClass',2288' Private x As Integer',2289'End Class',2290].join('\n'));2291});2292});22932294test('issue #118932: full program indentation flow', () => {22952296// https://github.com/microsoft/vscode/issues/1189322297// Verify the complete flow as described in the verification comment2298// Note: Auto-indent only triggers on typing the last character that completes a keyword2299// and only decreases by one indentation level per keyword completion23002301const model = createTextModel('', languageId, {});2302disposables.add(model);23032304withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2305// Type Module Test and press Enter2306viewModel.type('Module Test');2307viewModel.type('\n', 'keyboard');2308assert.strictEqual(model.getValue(), [2309'Module Test',2310' ',2311].join('\n'), 'After Module Test');23122313// Type Sub Main() and press Enter2314viewModel.type('Sub Main()');2315viewModel.type('\n', 'keyboard');2316assert.strictEqual(model.getValue(), [2317'Module Test',2318' Sub Main()',2319' ',2320].join('\n'), 'After Sub Main()');23212322// Type Console.WriteLine and press Enter2323viewModel.type('Console.WriteLine("Hello, World!")');2324viewModel.type('\n', 'keyboard');2325assert.strictEqual(model.getValue(), [2326'Module Test',2327' Sub Main()',2328' Console.WriteLine("Hello, World!")',2329' ',2330].join('\n'), 'After Console.WriteLine');23312332// Type End Su then 'b' to complete End Sub (auto-indent triggers on last char)2333viewModel.type('End Su');2334viewModel.type('b', 'keyboard');2335assert.strictEqual(model.getValue(), [2336'Module Test',2337' Sub Main()',2338' Console.WriteLine("Hello, World!")',2339' End Sub',2340].join('\n'), 'After End Sub');23412342// Press Enter - should maintain same indent level after End Sub2343viewModel.type('\n', 'keyboard');2344assert.strictEqual(model.getValue(), [2345'Module Test',2346' Sub Main()',2347' Console.WriteLine("Hello, World!")',2348' End Sub',2349' ',2350].join('\n'), 'After Enter after End Sub');2351});2352});2353});235423552356suite('Auto Indent On Type - Latex', () => {23572358const languageId = Language.Latex;2359let disposables: DisposableStore;2360let serviceCollection: ServiceCollection;23612362setup(() => {2363disposables = new DisposableStore();2364const languageService = new LanguageService();2365const languageConfigurationService = new TestLanguageConfigurationService();2366disposables.add(languageService);2367disposables.add(languageConfigurationService);2368disposables.add(registerLanguage(languageService, languageId));2369disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));2370serviceCollection = new ServiceCollection(2371[ILanguageService, languageService],2372[ILanguageConfigurationService, languageConfigurationService]2373);2374});23752376teardown(() => {2377disposables.dispose();2378});23792380ensureNoDisposablesAreLeakedInTestSuite();23812382test('temp issue because there should be at least one passing test in a suite', () => {2383assert.ok(true);2384});23852386test.skip('issue #178075: no auto closing pair when indentation done', () => {23872388// https://github.com/microsoft/vscode/issues/17807523892390const model = createTextModel([2391'\\begin{theorem}',2392' \\end',2393].join('\n'), languageId, {});2394disposables.add(model);23952396withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2397editor.setSelection(new Selection(2, 9, 2, 9));2398viewModel.type('{', 'keyboard');2399assert.strictEqual(model.getValue(), [2400'\\begin{theorem}',2401'\\end{}',2402].join('\n'));2403});2404});2405});24062407suite('Auto Indent On Type - Lua', () => {24082409const languageId = Language.Lua;2410let disposables: DisposableStore;2411let serviceCollection: ServiceCollection;24122413setup(() => {2414disposables = new DisposableStore();2415const languageService = new LanguageService();2416const languageConfigurationService = new TestLanguageConfigurationService();2417disposables.add(languageService);2418disposables.add(languageConfigurationService);2419disposables.add(registerLanguage(languageService, languageId));2420disposables.add(registerLanguageConfiguration(languageConfigurationService, languageId));2421serviceCollection = new ServiceCollection(2422[ILanguageService, languageService],2423[ILanguageConfigurationService, languageConfigurationService]2424);2425});24262427teardown(() => {2428disposables.dispose();2429});24302431ensureNoDisposablesAreLeakedInTestSuite();24322433test('temp issue because there should be at least one passing test in a suite', () => {2434assert.ok(true);2435});24362437test.skip('issue #178075: no auto closing pair when indentation done', () => {24382439// https://github.com/microsoft/vscode/issues/17807524402441const model = createTextModel([2442'print("asdf function asdf")',2443].join('\n'), languageId, {});2444disposables.add(model);24452446withTestCodeEditor(model, { autoIndent: 'full', serviceCollection }, (editor, viewModel) => {2447editor.setSelection(new Selection(1, 28, 1, 28));2448viewModel.type('\n', 'keyboard');2449assert.strictEqual(model.getValue(), [2450'print("asdf function asdf")',2451''2452].join('\n'));2453});2454});2455});245624572458