diff --git a/src/api/errors/diagnostics.ts b/src/api/errors/diagnostics.ts index 7282793b9..e669a46d6 100644 --- a/src/api/errors/diagnostics.ts +++ b/src/api/errors/diagnostics.ts @@ -1,11 +1,11 @@ import * as vscode from "vscode"; -import Instance from "../Instance"; -import { parseErrors } from "./parser"; import { FileError } from "../../typings"; -import { getEvfeventFiles } from "../local/actions"; import { GlobalConfiguration } from "../Configuration"; +import Instance from "../Instance"; import { Tools } from "../Tools"; +import { getEvfeventFiles } from "../local/actions"; +import { parseErrors } from "./parser"; const ileDiagnostics = vscode.languages.createDiagnosticCollection(`ILE`); @@ -55,7 +55,7 @@ export function clearDiagnostic(uri: vscode.Uri, changeRange: vscode.Range) { const existing = currentList.findIndex(d => d.range.contains(changeRange)); if (existing >= 0) { - const newList = [...currentList.slice(0, existing), ...currentList.slice(existing+1)]; + const newList = [...currentList.slice(0, existing), ...currentList.slice(existing + 1)]; ileDiagnostics.set(uri, newList); } @@ -105,7 +105,7 @@ export async function refreshDiagnosticsFromLocal(instance: Instance, evfeventIn } } -export async function handleEvfeventLines(lines: string[], instance: Instance, evfeventInfo: EvfEventInfo) { +export function handleEvfeventLines(lines: string[], instance: Instance, evfeventInfo: EvfEventInfo) { const connection = instance.getConnection(); const config = instance.getConfig(); const asp = evfeventInfo.asp ? `${evfeventInfo.asp}/` : ``; @@ -150,36 +150,39 @@ export async function handleEvfeventLines(lines: string[], instance: Instance, e if (workspaceFolder && storage) { const workspaceDeployPath = storage.getWorkspaceDeployPath(workspaceFolder); const deployPathIndex = file.toLowerCase().indexOf(workspaceDeployPath.toLowerCase()); - - let relativeCompilePath = (deployPathIndex !== -1 ? file.substring(0, deployPathIndex) + file.substring(deployPathIndex + workspaceDeployPath.length) : file); - - if (connection) { - // Belive it or not, sometimes if the deploy directory is symlinked into as ASP, this can be a problem - const aspNames = Object.values(connection.aspInfo); - for (const aspName of aspNames) { - const aspRoot = `/${aspName}`; - if (relativeCompilePath.startsWith(aspRoot)) { - relativeCompilePath = relativeCompilePath.substring(aspRoot.length); - break; + + let relativeCompilePath = (deployPathIndex !== -1 ? file.substring(0, deployPathIndex) + file.substring(deployPathIndex + workspaceDeployPath.length) : undefined); + + if (relativeCompilePath) { + if (connection) { + // Belive it or not, sometimes if the deploy directory is symlinked into as ASP, this can be a problem + const aspNames = Object.values(connection.aspInfo); + for (const aspName of aspNames) { + const aspRoot = `/${aspName}`; + if (relativeCompilePath.startsWith(aspRoot)) { + relativeCompilePath = relativeCompilePath.substring(aspRoot.length); + break; + } } } - } - - const diagnosticTargetFile = vscode.Uri.joinPath(workspaceFolder.uri, relativeCompilePath); - if (diagnosticTargetFile !== undefined) { - ileDiagnostics.set(diagnosticTargetFile, diagnostics); - } else { - vscode.window.showWarningMessage("Couldn't show compile error(s) in problem view."); + const diagnosticTargetFile = vscode.Uri.joinPath(workspaceFolder.uri, relativeCompilePath); + if (diagnosticTargetFile !== undefined) { + ileDiagnostics.set(diagnosticTargetFile, diagnostics); + } else { + vscode.window.showWarningMessage("Couldn't show compile error(s) in problem view."); + } + continue; } } - } else { - if (file.startsWith(`/`)) - ileDiagnostics.set(Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `streamfile`, path: file })), diagnostics); - else { - const memberUri = Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `member`, path: `/${asp}${file}${evfeventInfo.extension ? `.` + evfeventInfo.extension : ``}` })); - ileDiagnostics.set(memberUri, diagnostics); - } + } + + if (file.startsWith(`/`)) { + ileDiagnostics.set(Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `streamfile`, path: file })), diagnostics); + } + else { + const memberUri = Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `member`, path: `/${asp}${file}${evfeventInfo.extension ? `.` + evfeventInfo.extension : ``}` })); + ileDiagnostics.set(memberUri, diagnostics); } } } else {