-
Notifications
You must be signed in to change notification settings - Fork 3
add remove option on parser failed notification #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,16 +32,24 @@ export class CodeBlocksEditorProvider implements vscode.CustomTextEditorProvider | |||||||||||||||||
| let language = await Installer.getLanguage(this.extensionParsersDirPath, languageId); | ||||||||||||||||||
|
|
||||||||||||||||||
| while (language.status !== "ok") { | ||||||||||||||||||
| const items = | ||||||||||||||||||
| language.result.cause === "loadFailed" | ||||||||||||||||||
| ? (["Remove", "Ok"] as const) | ||||||||||||||||||
| : (["Retry", "Ok"] as const); | ||||||||||||||||||
|
|
||||||||||||||||||
| const choice = await vscode.window.showErrorMessage( | ||||||||||||||||||
| `Parser installation failed: ${language.result}`, | ||||||||||||||||||
| "Retry", | ||||||||||||||||||
| "Ok" | ||||||||||||||||||
| `Parser installation failed: ${JSON.stringify(language.result)}`, | ||||||||||||||||||
| ...items | ||||||||||||||||||
| ); | ||||||||||||||||||
| if (choice !== "Retry") { | ||||||||||||||||||
|
|
||||||||||||||||||
| if (choice === "Remove") { | ||||||||||||||||||
| Installer.removeLanguage(this.extensionParsersDirPath, languageId); | ||||||||||||||||||
|
||||||||||||||||||
| 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)}` | |
| ); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,15 +1,14 @@ | ||||||
| import * as BlockMode from "./BlockMode"; | ||||||
| import * as Installer from "./Installer"; | ||||||
| import * as configuration from "./configuration"; | ||||||
| import * as vscode from "vscode"; | ||||||
| import { CodeBlocksEditorProvider } from "./editor/CodeBlocksEditorProvider"; | ||||||
| import { FileTree } from "./FileTree"; | ||||||
| import { TreeViewer } from "./TreeViewer"; | ||||||
| import { getLanguage } from "./Installer"; | ||||||
| import { getLogger } from "./outputChannel"; | ||||||
| import { join } from "path"; | ||||||
| import { state } from "./state"; | ||||||
|
|
||||||
| export const parserFinishedInit = Promise.resolve(); | ||||||
|
|
||||||
| async function reopenWithCodeBocksEditor(): Promise<void> { | ||||||
| const activeTabInput = vscode.window.tabGroups.activeTabGroup.activeTab?.input as { | ||||||
| [key: string]: unknown; | ||||||
|
|
@@ -45,25 +44,47 @@ async function getEditorFileTree( | |||||
| } | ||||||
|
|
||||||
| const activeDocument = editor.document; | ||||||
| const language = await getLanguage(parsersDir, activeDocument.languageId); | ||||||
| if (language.status === "err" || language.result === undefined) { | ||||||
| if (language.status === "err") { | ||||||
| void vscode.window.showErrorMessage(`Failed to get language: ${language.result}`); | ||||||
| } else { | ||||||
| logger.log(`No language found for ${activeDocument.languageId}`); | ||||||
| const languageId = activeDocument.languageId; | ||||||
| const language = await Installer.getLanguage(parsersDir, languageId); | ||||||
|
|
||||||
| // sup-optimal conditional to make tsc happy | ||||||
|
||||||
| // sup-optimal conditional to make tsc happy | |
| // sub-optimal conditional to make tsc happy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
awaitkeyword. TheremoveLanguagefunction performs file system operations (rmSync) that could throw errors. WhilermSyncis synchronous, the call should beawaited or the function should handle potential errors, especially since this is called from an async context where error handling would be expected.