2
0
Эх сурвалжийг харах

Only include errors in automatic problems report after edits

Saoud Rizwan 1 жил өмнө
parent
commit
62cd1a74cb

+ 7 - 1
src/core/ClaudeDev.ts

@@ -859,7 +859,13 @@ export class ClaudeDev {
 			initial fix is usually correct and it may just take time for linters to catch up.
 			initial fix is usually correct and it may just take time for linters to catch up.
 			*/
 			*/
 			const postDiagnostics = vscode.languages.getDiagnostics()
 			const postDiagnostics = vscode.languages.getDiagnostics()
-			const newProblems = diagnosticsToProblemsString(getNewDiagnostics(preDiagnostics, postDiagnostics), cwd) // will be empty string if no errors/warnings
+			const newProblems = diagnosticsToProblemsString(
+				getNewDiagnostics(preDiagnostics, postDiagnostics),
+				[
+					vscode.DiagnosticSeverity.Error, // only including errors since warnings can be distracting (if user wants to fix warnings they can use the @problems mention)
+				],
+				cwd
+			) // will be empty string if no errors
 			const newProblemsMessage =
 			const newProblemsMessage =
 				newProblems.length > 0 ? `\n\nNew problems detected after saving the file:\n${newProblems}` : ""
 				newProblems.length > 0 ? `\n\nNew problems detected after saving the file:\n${newProblems}` : ""
 			// await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), { preview: false })
 			// await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), { preview: false })

+ 5 - 1
src/core/mentions/index.ts

@@ -171,7 +171,11 @@ async function getFileOrFolderContent(mentionPath: string, cwd: string): Promise
 
 
 function getWorkspaceProblems(cwd: string): string {
 function getWorkspaceProblems(cwd: string): string {
 	const diagnostics = vscode.languages.getDiagnostics()
 	const diagnostics = vscode.languages.getDiagnostics()
-	const result = diagnosticsToProblemsString(diagnostics, cwd)
+	const result = diagnosticsToProblemsString(
+		diagnostics,
+		[vscode.DiagnosticSeverity.Error, vscode.DiagnosticSeverity.Warning],
+		cwd
+	)
 	if (!result) {
 	if (!result) {
 		return "No errors or warnings detected."
 		return "No errors or warnings detected."
 	}
 	}

+ 25 - 7
src/integrations/diagnostics/index.ts

@@ -69,20 +69,38 @@ export function getNewDiagnostics(
 // // File: /path/to/file3.ts
 // // File: /path/to/file3.ts
 // // - New error in file3 (1:1)
 // // - New error in file3 (1:1)
 
 
-// will return empty string if no errors/warnings
-export function diagnosticsToProblemsString(diagnostics: [vscode.Uri, vscode.Diagnostic[]][], cwd: string): string {
+// will return empty string if no problems with the given severity are found
+export function diagnosticsToProblemsString(
+	diagnostics: [vscode.Uri, vscode.Diagnostic[]][],
+	severities: vscode.DiagnosticSeverity[],
+	cwd: string
+): string {
 	let result = ""
 	let result = ""
 	for (const [uri, fileDiagnostics] of diagnostics) {
 	for (const [uri, fileDiagnostics] of diagnostics) {
-		const problems = fileDiagnostics.filter(
-			(d) => d.severity === vscode.DiagnosticSeverity.Error || d.severity === vscode.DiagnosticSeverity.Warning
-		)
+		const problems = fileDiagnostics.filter((d) => severities.includes(d.severity))
 		if (problems.length > 0) {
 		if (problems.length > 0) {
 			result += `\n\n${path.relative(cwd, uri.fsPath).toPosix()}`
 			result += `\n\n${path.relative(cwd, uri.fsPath).toPosix()}`
 			for (const diagnostic of problems) {
 			for (const diagnostic of problems) {
-				let severity = diagnostic.severity === vscode.DiagnosticSeverity.Error ? "Error" : "Warning"
+				let label: string
+				switch (diagnostic.severity) {
+					case vscode.DiagnosticSeverity.Error:
+						label = "Error"
+						break
+					case vscode.DiagnosticSeverity.Warning:
+						label = "Warning"
+						break
+					case vscode.DiagnosticSeverity.Information:
+						label = "Information"
+						break
+					case vscode.DiagnosticSeverity.Hint:
+						label = "Hint"
+						break
+					default:
+						label = "Diagnostic"
+				}
 				const line = diagnostic.range.start.line + 1 // VSCode lines are 0-indexed
 				const line = diagnostic.range.start.line + 1 // VSCode lines are 0-indexed
 				const source = diagnostic.source ? `${diagnostic.source} ` : ""
 				const source = diagnostic.source ? `${diagnostic.source} ` : ""
-				result += `\n- [${source}${severity}] Line ${line}: ${diagnostic.message}`
+				result += `\n- [${source}${label}] Line ${line}: ${diagnostic.message}`
 			}
 			}
 		}
 		}
 	}
 	}