Skip to content

Commit 295e497

Browse files
authored
fix: Avoid deleting original file (#56)
1 parent 1605c11 commit 295e497

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/views/ProblemsDiagnosticCollection.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ export class ProblemsDiagnosticCollection implements vscode.Disposable {
191191

192192
if (!isCliInstalled || !codacyConfigExists) return
193193

194-
let pathToFile = document.uri.fsPath
194+
const originalPath = document.uri.fsPath
195+
let pathToFile = originalPath
195196

196197
try {
197198
this._isAnalysisRunning = true
@@ -222,15 +223,15 @@ export class ProblemsDiagnosticCollection implements vscode.Disposable {
222223
// Run the local analysis
223224
const results = await runCodacyAnalyze(pathToFile)
224225

225-
this._currentCliIssues[document.uri.fsPath] = results
226+
this._currentCliIssues[originalPath] = results
226227

227228
this.updateDocumentDiagnostics(document)
228229
} catch (error) {
229230
console.error('Failed to process Codacy analysis:', error)
230231
} finally {
231232
this._isAnalysisRunning = false
232233

233-
if (document.isDirty) {
234+
if (document.isDirty && pathToFile !== originalPath) {
234235
// Remove the temporary file after analysis with retries
235236
const deleted = await this.retryDeleteFile(pathToFile)
236237
if (!deleted) {

0 commit comments

Comments
 (0)