Skip to content

Commit de115bb

Browse files
committed
feat(clear logs): clear logs when file is removed
1 parent e9159a4 commit de115bb

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

dist/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "acode-plugin-prettier",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Acode plugin to format code",
55
"main": "dist/main.js",
66
"repository": "https://github.com/deadlyjack/acode-plugin-prettier.git",

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "acode.plugin.prettier",
33
"name": "Prettier",
44
"main": "dist/main.js",
5-
"version": "2.0.0",
5+
"version": "2.0.1",
66
"readme": "readme.md",
77
"icon": "icon.png",
88
"type": "free",

src/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class AcodePrettier {
5353
constructor() {
5454
this.run = this.run.bind(this);
5555
this.onSettingsChange = this.onSettingsChange.bind(this);
56+
this.removeErrorsByFile = this.removeErrorsByFile.bind(this);
5657
this.#sideButton = SideButton?.({
5758
text: plugin.name,
5859
icon: "warningreport_problem",
@@ -148,6 +149,7 @@ class AcodePrettier {
148149
];
149150

150151
acode.registerFormatter(pluginId, extensions, this.run);
152+
editorManager.on('remove-file', this.removeErrorsByFile);
151153
}
152154

153155
async run() {
@@ -196,6 +198,7 @@ class AcodePrettier {
196198
this.commands.forEach(command => {
197199
editorManager.editor.commands.removeCommand(command);
198200
});
201+
editorManager.off('remove-file', this.removeErrorsByFile);
199202
}
200203

201204
#cursorPosToCursorOffset(cursorPos) {
@@ -321,6 +324,10 @@ class AcodePrettier {
321324
}
322325
}
323326

327+
removeErrorsByFile(file) {
328+
this.#removeErrors(file.id);
329+
}
330+
324331
#removeErrors(fileId) {
325332
const $errors = this.#page.getAll(`[data-file="${fileId}"]`);
326333
$errors.forEach($error => $error.remove());

0 commit comments

Comments
 (0)