From b9909b835fca5154560b5caa0825639ab9e2377a Mon Sep 17 00:00:00 2001 From: Phillip Rak Date: Wed, 4 Dec 2024 16:46:39 -0700 Subject: [PATCH] Remove `onChanges()` method in `ResourceYaml.vue` This removes the `onChanges()` method from `ResourceYaml.vue` because the intent of the code is not clear and appears to provide no benefit in testing. This is a source of frustration for some users, making it impossible to add comments to YAML. It appears that this function exists to automatically adjust the indentation of comment lines; it has failed to accomplish this task during testing, so it appears to be meaningless. If users wish to format yaml, we should support this with an explicit action in the YAML editor, not something that is performed on every keypress. Signed-off-by: Phillip Rak --- shell/components/ResourceYaml.vue | 53 ------------------------------- 1 file changed, 53 deletions(-) diff --git a/shell/components/ResourceYaml.vue b/shell/components/ResourceYaml.vue index 4858e684ce9..b3ab30ae25e 100644 --- a/shell/components/ResourceYaml.vue +++ b/shell/components/ResourceYaml.vue @@ -205,58 +205,6 @@ export default { cm.getMode().fold = saved; }, - onChanges(cm, changes) { - if ( changes.length !== 1 ) { - return; - } - - const change = changes[0]; - - if ( change.from.line !== change.to.line ) { - return; - } - - let line = change.from.line; - let str = cm.getLine(line); - let maxIndent = indentChars(str); - - if ( maxIndent === null ) { - return; - } - - cm.replaceRange('', { line, ch: 0 }, { line, ch: 1 }, '+input'); - - while ( line > 0 ) { - line--; - str = cm.getLine(line); - const indent = indentChars(str); - - if ( indent === null ) { - break; - } - - if ( indent < maxIndent ) { - cm.replaceRange('', { line, ch: 0 }, { line, ch: 1 }, '+input'); - - if ( indent === 0 ) { - break; - } - - maxIndent = indent; - } - } - - function indentChars(str) { - const match = str.match(/^#(\s+)/); - - if ( match ) { - return match[1].length; - } - - return null; - } - }, - updateValue(value) { this.$refs.yamleditor.updateValue(value); }, @@ -354,7 +302,6 @@ export default { class="yaml-editor flex-content" :editor-mode="editorMode" @onReady="onReady" - @onChanges="onChanges" />