1
0
Эх сурвалжийг харах

Add yaml indent action

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`.
Remco Haszing 3 жил өмнө
parent
commit
8e34418a64

+ 10 - 2
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 = <languages.IMonarchLanguage>{