Skip to content

Commit 2f75a99

Browse files
Support staging and unstaging entire files with git actions
1 parent 3e84a12 commit 2f75a99

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

packages/cursorless-vscode/src/ide/vscode/VscodeTextEditorImpl.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,25 @@ export class VscodeTextEditorImpl implements EditableTextEditor {
252252
}
253253

254254
public async gitStage(_range?: Range): Promise<void> {
255-
await vscode.commands.executeCommand("git.stageSelectedRanges");
255+
if (this.selectionIsEntireFile()) {
256+
await vscode.commands.executeCommand("git.stage");
257+
} else {
258+
await vscode.commands.executeCommand("git.stageSelectedRanges");
259+
}
256260
}
257261

258262
public async gitUnstage(_range?: Range): Promise<void> {
259-
await vscode.commands.executeCommand("git.unstageSelectedRanges");
263+
if (this.selectionIsEntireFile()) {
264+
await vscode.commands.executeCommand("git.unstage");
265+
} else {
266+
await vscode.commands.executeCommand("git.unstageSelectedRanges");
267+
}
268+
}
269+
270+
private selectionIsEntireFile(): boolean {
271+
return (
272+
this.selections.length === 1 &&
273+
this.selections[0].isRangeEqual(this.document.range)
274+
);
260275
}
261276
}

0 commit comments

Comments
 (0)