File tree Expand file tree Collapse file tree
packages/cursorless-vscode/src/ide/vscode Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments