From a7400fc99fa21834fe37ebf9077dd0faeaa58374 Mon Sep 17 00:00:00 2001 From: Sergi Philipsen Date: Thu, 1 Oct 2020 15:06:28 +0200 Subject: [PATCH] Add auto indent for xml --- src/xml/xml.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/xml/xml.ts b/src/xml/xml.ts index 8d2cd90c..0c1a345a 100644 --- a/src/xml/xml.ts +++ b/src/xml/xml.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { languages } from '../fillers/monaco-editor-core'; +import { languages } from '../fillers/monaco-editor-core'; export const conf: languages.LanguageConfiguration = { comments: { @@ -19,6 +19,19 @@ export const conf: languages.LanguageConfiguration = { { open: '<', close: '>' }, { open: "'", close: "'" }, { open: '"', close: '"' } + ], + onEnterRules: [ + { + beforeText: new RegExp(`<([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'), + afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i, + action: { + indentAction: languages.IndentAction.IndentOutdent + } + }, + { + beforeText: new RegExp(`<(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'), + action: { indentAction: languages.IndentAction.Indent } + } ] };