Skip to content

Commit d5a0086

Browse files
Copilotalexr00
andcommitted
Address code review feedback - safer type checking
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent f1f1684 commit d5a0086

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/view/treeNodes/fileChangeNode.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ export class FileChangeNode extends TreeNode implements vscode.TreeItem {
163163
let current = this.parent;
164164
while (current instanceof TreeNode) {
165165
// CommitNode has contextValue set to 'commit'
166-
if ((current as vscode.TreeItem).contextValue === 'commit') {
166+
// Since TreeNode doesn't define contextValue, we check if it exists and equals 'commit'
167+
const treeItem = current as { contextValue?: string };
168+
if (treeItem.contextValue === 'commit') {
167169
return true;
168170
}
169171
current = current.parent;

src/view/treeNodes/treeUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export namespace TreeUtils {
3535
continue;
3636
}
3737
if (!checkedNodes.includes(selected) && !uncheckedNodes.includes(selected)) {
38+
// Only process files that have checkboxes (files without checkboxState, like those under commits, are skipped)
3839
if (selected.checkboxState?.state === vscode.TreeItemCheckboxState.Unchecked) {
3940
checkedNodes.push(selected);
4041
} else if (selected.checkboxState?.state === vscode.TreeItemCheckboxState.Checked) {

0 commit comments

Comments
 (0)