mirror of
https://github.com/louislam/dockge.git
synced 2025-03-13 12:54:48 +00:00
Compare commits
1 commit
9d19c6476a
...
a5bf872a42
Author | SHA1 | Date | |
---|---|---|---|
|
a5bf872a42 |
2 changed files with 22 additions and 42 deletions
|
@ -236,31 +236,25 @@ export function copyYAMLComments(doc : Document, src : Document) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy yaml comments from srcItems to items
|
* Copy yaml comments from srcItems to items
|
||||||
* Attempts to preserve comments by matching content rather than just array indices
|
* Typescript is super annoying here, so I have to use any here
|
||||||
|
* 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 srcIndex = srcItems.findIndex((srcItem: any) =>
|
const srcItem : any = srcItems[i];
|
||||||
JSON.stringify(srcItem.value) === JSON.stringify(item.value) &&
|
|
||||||
JSON.stringify(srcItem.key) === JSON.stringify(item.key)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (srcIndex !== -1) {
|
if (!srcItem) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
continue;
|
||||||
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;
|
||||||
|
@ -271,20 +265,6 @@ 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;
|
||||||
|
@ -296,7 +276,6 @@ function copyYAMLCommentsItems(items: any, srcItems: any) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -247,6 +247,7 @@ 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