From 8e34418a64677a09914ca135fc6e7c2ac14be7b6 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Tue, 5 Apr 2022 11:02:00 +0200 Subject: [PATCH] Add yaml indent action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a line ends with `:` and a user presses Enter, they are probably defining an object, which requires indentation. This rule is taken from `monaco-yaml`, but I intend to remove basic language support there, since that’s already part of `monaco-editor`. --- src/basic-languages/yaml/yaml.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/basic-languages/yaml/yaml.ts b/src/basic-languages/yaml/yaml.ts index 35095592..466be144 100644 --- a/src/basic-languages/yaml/yaml.ts +++ b/src/basic-languages/yaml/yaml.ts @@ -1,4 +1,4 @@ -import type { languages } from '../../fillers/monaco-editor-core'; +import { languages } from '../../fillers/monaco-editor-core'; export const conf: languages.LanguageConfiguration = { comments: { @@ -25,7 +25,15 @@ export const conf: languages.LanguageConfiguration = { ], folding: { offSide: true - } + }, + onEnterRules: [ + { + beforeText: /:\s*$/, + action: { + indentAction: languages.IndentAction.Indent + } + } + ] }; export const language = {