mirror of
https://github.com/louislam/dockge.git
synced 2025-03-14 13:24:50 +00:00
Compare commits
4 commits
402718c701
...
947f40a033
Author | SHA1 | Date | |
---|---|---|---|
|
947f40a033 | ||
|
a65a9f5549 | ||
|
9b73e44cd9 | ||
|
4d71a44d5b |
2 changed files with 42 additions and 24 deletions
|
@ -236,25 +236,31 @@ export function copyYAMLComments(doc : Document, src : Document) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy yaml comments from srcItems to items
|
* Copy yaml comments from srcItems to items
|
||||||
* Typescript is super annoying here, so I have to use any here
|
* Attempts to preserve comments by matching content rather than just array indices
|
||||||
* TODO: Since comments are belong to the array index, the comments will be lost if the order of the items is changed or removed or added.
|
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function copyYAMLCommentsItems(items : any, srcItems : any) {
|
function copyYAMLCommentsItems(items: any, srcItems: any) {
|
||||||
if (!items || !srcItems) {
|
if (!items || !srcItems) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First pass - try to match items by their content
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const item : any = items[i];
|
const item: any = items[i];
|
||||||
|
|
||||||
|
// Try to find matching source item by content
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const srcItem : any = srcItems[i];
|
const srcIndex = srcItems.findIndex((srcItem: any) =>
|
||||||
|
JSON.stringify(srcItem.value) === JSON.stringify(item.value) &&
|
||||||
|
JSON.stringify(srcItem.key) === JSON.stringify(item.key)
|
||||||
|
);
|
||||||
|
|
||||||
if (!srcItem) {
|
if (srcIndex !== -1) {
|
||||||
continue;
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
}
|
const srcItem: any = srcItems[srcIndex];
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const nextSrcItem: any = srcItems[srcIndex + 1];
|
||||||
|
|
||||||
if (item.key && srcItem.key) {
|
if (item.key && srcItem.key) {
|
||||||
item.key.comment = srcItem.key.comment;
|
item.key.comment = srcItem.key.comment;
|
||||||
|
@ -265,6 +271,20 @@ function copyYAMLCommentsItems(items : any, srcItems : any) {
|
||||||
item.comment = srcItem.comment;
|
item.comment = srcItem.comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle comments between array items
|
||||||
|
if (nextSrcItem && nextSrcItem.commentBefore) {
|
||||||
|
if (items[i + 1]) {
|
||||||
|
items[i + 1].commentBefore = nextSrcItem.commentBefore;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle trailing comments after array items
|
||||||
|
if (srcItem.value && srcItem.value.comment) {
|
||||||
|
if (item.value) {
|
||||||
|
item.value.comment = srcItem.value.comment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (item.value && srcItem.value) {
|
if (item.value && srcItem.value) {
|
||||||
if (typeof item.value === "object" && typeof srcItem.value === "object") {
|
if (typeof item.value === "object" && typeof srcItem.value === "object") {
|
||||||
item.value.comment = srcItem.value.comment;
|
item.value.comment = srcItem.value.comment;
|
||||||
|
@ -276,6 +296,7 @@ function copyYAMLCommentsItems(items : any, srcItems : any) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -164,7 +164,6 @@ export default {
|
||||||
mainTerminalConfig() {
|
mainTerminalConfig() {
|
||||||
this.terminal.onKey(e => {
|
this.terminal.onKey(e => {
|
||||||
const code = e.key.charCodeAt(0);
|
const code = e.key.charCodeAt(0);
|
||||||
console.debug("Encode: " + JSON.stringify(e.key));
|
|
||||||
|
|
||||||
if (e.key === "\r") {
|
if (e.key === "\r") {
|
||||||
// Return if no input
|
// Return if no input
|
||||||
|
@ -201,7 +200,6 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
this.cursorPosition++;
|
this.cursorPosition++;
|
||||||
this.terminalInputBuffer += e.key;
|
this.terminalInputBuffer += e.key;
|
||||||
console.log(this.terminalInputBuffer);
|
|
||||||
this.terminal.write(e.key);
|
this.terminal.write(e.key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -247,7 +245,6 @@ export default {
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.main-terminal {
|
.main-terminal {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-x: scroll;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue