Revert "fix: improve VS Code config synchronization and code formatting"
This reverts commit 463e430a3d.
This commit is contained in:
@@ -22,10 +22,7 @@ const deepMerge = (
|
||||
return target;
|
||||
};
|
||||
|
||||
const deepRemove = (
|
||||
target: Record<string, any>,
|
||||
source: Record<string, any>,
|
||||
) => {
|
||||
const deepRemove = (target: Record<string, any>, source: Record<string, any>) => {
|
||||
Object.entries(source).forEach(([key, value]) => {
|
||||
if (!(key in target)) return;
|
||||
|
||||
@@ -62,7 +59,7 @@ const isSubset = (target: any, source: any): boolean => {
|
||||
const deepClone = <T>(obj: T): T => {
|
||||
if (obj === null || typeof obj !== "object") return obj;
|
||||
if (obj instanceof Date) return new Date(obj.getTime()) as T;
|
||||
if (obj instanceof Array) return obj.map((item) => deepClone(item)) as T;
|
||||
if (obj instanceof Array) return obj.map(item => deepClone(item)) as T;
|
||||
if (obj instanceof Object) {
|
||||
const clonedObj = {} as T;
|
||||
for (const key in obj) {
|
||||
@@ -81,10 +78,7 @@ export interface UpdateCommonConfigResult {
|
||||
}
|
||||
|
||||
// 验证JSON配置格式
|
||||
export const validateJsonConfig = (
|
||||
value: string,
|
||||
fieldName: string = "配置",
|
||||
): string => {
|
||||
export const validateJsonConfig = (value: string, fieldName: string = "配置"): string => {
|
||||
if (!value.trim()) {
|
||||
return "";
|
||||
}
|
||||
@@ -129,7 +123,7 @@ export const updateCommonConfigSnippet = (
|
||||
error: snippetError,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
const snippet = JSON.parse(snippetString) as Record<string, any>;
|
||||
|
||||
if (enabled) {
|
||||
@@ -253,23 +247,23 @@ export const updateTomlCommonConfigSnippet = (
|
||||
const removeTomlCommonConfig = (tomlString: string): string => {
|
||||
const startIdx = tomlString.indexOf(COMMON_CONFIG_MARKER_START);
|
||||
const endIdx = tomlString.indexOf(COMMON_CONFIG_MARKER_END);
|
||||
|
||||
|
||||
if (startIdx === -1 || endIdx === -1) {
|
||||
return tomlString;
|
||||
}
|
||||
|
||||
|
||||
// 找到标记前的换行符(如果有)
|
||||
let realStartIdx = startIdx;
|
||||
if (startIdx > 0 && tomlString[startIdx - 1] === "\n") {
|
||||
if (startIdx > 0 && tomlString[startIdx - 1] === '\n') {
|
||||
realStartIdx = startIdx - 1;
|
||||
}
|
||||
|
||||
|
||||
// 找到标记后的换行符(如果有)
|
||||
let realEndIdx = endIdx + COMMON_CONFIG_MARKER_END.length;
|
||||
if (realEndIdx < tomlString.length && tomlString[realEndIdx] === "\n") {
|
||||
if (realEndIdx < tomlString.length && tomlString[realEndIdx] === '\n') {
|
||||
realEndIdx = realEndIdx + 1;
|
||||
}
|
||||
|
||||
|
||||
return tomlString.slice(0, realStartIdx) + tomlString.slice(realEndIdx);
|
||||
};
|
||||
|
||||
@@ -279,19 +273,19 @@ export const hasTomlCommonConfigSnippet = (
|
||||
snippetString: string,
|
||||
): boolean => {
|
||||
if (!snippetString.trim()) return false;
|
||||
|
||||
|
||||
const startIdx = tomlString.indexOf(COMMON_CONFIG_MARKER_START);
|
||||
const endIdx = tomlString.indexOf(COMMON_CONFIG_MARKER_END);
|
||||
|
||||
|
||||
if (startIdx === -1 || endIdx === -1 || startIdx >= endIdx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 提取标记之间的内容
|
||||
const existingSnippet = tomlString
|
||||
.slice(startIdx + COMMON_CONFIG_MARKER_START.length, endIdx)
|
||||
.trim();
|
||||
|
||||
|
||||
return existingSnippet === snippetString.trim();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user