Skip to content

Commit

Permalink
🩹 properly dispose of diff handler
Browse files Browse the repository at this point in the history
  • Loading branch information
sestinj committed May 16, 2024
1 parent 7857c4c commit 3b45028
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/static/schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,9 @@
"enum": ["top", "bottom"],
"default": "top",
"description": "Whether to show the copy and apply code buttons at the top or bottom of code blocks in the sidebar."
},
"fontSize": {
"type": "number"
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions extensions/intellij/src/main/resources/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,9 @@
"enum": ["top", "bottom"],
"default": "top",
"description": "Whether to show the copy and apply code buttons at the top or bottom of code blocks in the sidebar."
},
"fontSize": {
"type": "number"
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions extensions/vscode/continue_rc_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,9 @@
],
"default": "top",
"description": "Whether to show the copy and apply code buttons at the top or bottom of code blocks in the sidebar."
},
"fontSize": {
"type": "number"
}
}
},
Expand Down
12 changes: 10 additions & 2 deletions extensions/vscode/src/diff/verticalPerLine/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "./decorations";
import { VerticalDiffCodeLens } from "./manager";

export class VerticalPerLineDiffHandler {
export class VerticalPerLineDiffHandler implements vscode.Disposable {
private editor: vscode.TextEditor;
private startLine: number;
private endLine: number;
Expand Down Expand Up @@ -56,7 +56,7 @@ export class VerticalPerLineDiffHandler {
this.editor,
);

vscode.window.onDidChangeActiveTextEditor((editor) => {
const disposable = vscode.window.onDidChangeActiveTextEditor((editor) => {
// When we switch away and back to this editor, need to re-draw decorations
if (editor?.document.uri.fsPath === this.filepath) {
this.editor = editor;
Expand All @@ -69,6 +69,7 @@ export class VerticalPerLineDiffHandler {
this.queueDiffLine(undefined);
}
});
this.disposables.push(disposable);
}

private get filepath() {
Expand Down Expand Up @@ -243,6 +244,13 @@ export class VerticalPerLineDiffHandler {

this.cancelled = true;
this.refreshCodeLens();
this.dispose();
}

disposables: vscode.Disposable[] = [];

dispose() {
this.disposables.forEach((disposable) => disposable.dispose());
}

get isCancelled() {
Expand Down

0 comments on commit 3b45028

Please sign in to comment.