Skip to content

add remove option on parser failed notification#181

Merged
selfint merged 4 commits into
mainfrom
180-add-option-to-delete-parser-if-load-failed
Oct 31, 2025
Merged

add remove option on parser failed notification#181
selfint merged 4 commits into
mainfrom
180-add-option-to-delete-parser-if-load-failed

Conversation

@selfint

@selfint selfint commented Dec 8, 2024

Copy link
Copy Markdown
Owner

No description provided.

@selfint selfint linked an issue Dec 8, 2024 that may be closed by this pull request
@selfint selfint requested a review from Copilot October 21, 2025 06:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to allow users to remove corrupted parser installations when loading fails. Previously, users could only retry or dismiss error messages when parser installation failed. Now, users can choose to remove a broken parser, with different options presented based on whether the failure was during download or loading.

Key changes:

  • Added "Remove" option to error notifications when parser loading fails
  • Implemented removeLanguage and askRemoveLanguage functions to handle parser removal
  • Removed unused parserFinishedInit promise that was previously used for initialization synchronization
  • Enhanced error handling with structured error types that distinguish between download and load failures

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Installer.ts Added GetLanguageError type, removeLanguage and askRemoveLanguage functions; updated getLanguage to return structured errors; removed parserFinishedInit references
src/extension.ts Updated error handling to use new askRemoveLanguage function; added conditional logic to handle download vs load failures; removed parserFinishedInit export
src/editor/CodeBlocksEditorProvider.ts Updated error dialog to show "Remove" option for load failures and use askRemoveLanguage; improved error message formatting
src/FileTree.ts Removed parserFinishedInit reference
src/test/suite/Installer.test.ts Updated error message to use JSON.stringify for consistency
CHANGELOG.md Documented the new "Remove" option feature

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/extension.ts
const languageId = activeDocument.languageId;
const language = await Installer.getLanguage(parsersDir, languageId);

// sup-optimal conditional to make tsc happy

Copilot AI Oct 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'sup-optimal' to 'sub-optimal'.

Suggested change
// sup-optimal conditional to make tsc happy
// sub-optimal conditional to make tsc happy

Copilot uses AI. Check for mistakes.
Comment thread src/Installer.ts
);

if (doRemove === "Remove") {
removeLanguage(parsersDir, languageId);

Copilot AI Oct 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing await keyword. The removeLanguage function performs file system operations (rmSync) that could throw errors. While rmSync is synchronous, the call should be awaited or the function should handle potential errors, especially since this is called from an async context where error handling would be expected.

Suggested change
removeLanguage(parsersDir, languageId);
try {
removeLanguage(parsersDir, languageId);
} catch (err) {
const logger = getLogger();
logger.log(`Failed to remove parser for ${languageId}: ${err}`);
vscode.window.showErrorMessage(`Failed to remove parser for ${languageId}: ${err}`);
}

Copilot uses AI. Check for mistakes.
if (choice !== "Retry") {

if (choice === "Remove") {
Installer.removeLanguage(this.extensionParsersDirPath, languageId);

Copilot AI Oct 21, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removeLanguage function can throw errors during file system operations, but this call is not wrapped in error handling. Consider adding try-catch or propagating errors to inform the user if removal fails.

Suggested change
Installer.removeLanguage(this.extensionParsersDirPath, languageId);
try {
Installer.removeLanguage(this.extensionParsersDirPath, languageId);
} catch (err) {
await vscode.window.showErrorMessage(
`Failed to remove language '${languageId}': ${err instanceof Error ? err.message : String(err)}`
);
}

Copilot uses AI. Check for mistakes.
@selfint selfint force-pushed the 180-add-option-to-delete-parser-if-load-failed branch from 2d469e9 to 4c746a7 Compare October 31, 2025 17:05
@selfint selfint added this to the v0.8.0 milestone Oct 31, 2025
@selfint selfint merged commit 3376fde into main Oct 31, 2025
10 of 12 checks passed
@selfint selfint deleted the 180-add-option-to-delete-parser-if-load-failed branch October 31, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to delete parser if load failed

2 participants