Skip to content

Commit

Permalink
Remove onChanges() method in ResourceYaml.vue
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rak-phillip committed Dec 4, 2024
1 parent 26cd5cc commit b9909b8
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions shell/components/ResourceYaml.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down Expand Up @@ -354,7 +302,6 @@ export default {
class="yaml-editor flex-content"
:editor-mode="editorMode"
@onReady="onReady"
@onChanges="onChanges"
/>
<slot
name="yamlFooter"
Expand Down

0 comments on commit b9909b8

Please sign in to comment.