Skip to content

Commit a8fdcd2

Browse files
committed
fix(vscode): RangeError: Invalid string length
1 parent 347709a commit a8fdcd2

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

src-vscode/src/extension.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,6 @@ const sortLoadedPrimaryLogSegments = <T extends { path: string; name: string; co
139139
})
140140
}
141141

142-
const combineLoadedPrimaryLogSegments = <T extends { path: string; name: string; content: string }>(
143-
entries: T[],
144-
): string => {
145-
const sorted = sortLoadedPrimaryLogSegments(entries)
146-
147-
let combined = ''
148-
for (const entry of sorted) {
149-
if (!entry.content) continue
150-
if (combined && !combined.endsWith('\n')) {
151-
combined += '\n'
152-
}
153-
combined += entry.content
154-
}
155-
return combined
156-
}
157-
158142
const postThemeChangedToWebview = (panel: vscode.WebviewPanel | undefined) => {
159143
panel?.webview.postMessage({
160144
type: 'vscodeThemeChanged',
@@ -795,9 +779,9 @@ async function handleZipFile(uri: vscode.Uri): Promise<void> {
795779
}
796780
})
797781
.filter((entry): entry is { path: string; name: string; content: string } => entry != null)
798-
const content = combineLoadedPrimaryLogSegments(loadedSegments)
782+
const primaryLogFiles = sortLoadedPrimaryLogSegments(loadedSegments)
799783

800-
if (!content) {
784+
if (primaryLogFiles.length === 0) {
801785
vscode.window.showWarningMessage('ZIP 文件中未找到有效的日志内容')
802786
return
803787
}
@@ -846,8 +830,10 @@ async function handleZipFile(uri: vscode.Uri): Promise<void> {
846830
}
847831

848832
currentPanel?.webview.postMessage({
849-
type: 'loadZipFile',
850-
content,
833+
type: 'loadFile',
834+
content: '',
835+
primaryLogFiles,
836+
fileName: path.posix.basename(uri.path),
851837
errorImages,
852838
visionImages,
853839
waitFreezesImages,

0 commit comments

Comments
 (0)