Skip to content

Commit

Permalink
add delete command (#149)
Browse files Browse the repository at this point in the history
* add delete command

* spaces

* remove logging
  • Loading branch information
howardcvalve authored and stef-levesque committed Apr 18, 2019
1 parent 7c5339f commit c8c9165
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@
"title": "edit - Open an existing file for edit",
"category": "Perforce"
},
{
"command": "perforce.delete",
"title": "delete - Delete an existing file",
"category": "Perforce"
},
{
"command": "perforce.revert",
"title": "revert - Discard changes from an opened file",
Expand Down
16 changes: 16 additions & 0 deletions src/PerforceCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export namespace PerforceCommands
export function registerCommands() {
commands.registerCommand('perforce.add', addOpenFile);
commands.registerCommand('perforce.edit', editOpenFile);
commands.registerCommand('perforce.delete', deleteOpenFile);
commands.registerCommand('perforce.revert', revert);
commands.registerCommand('perforce.diff', diff);
commands.registerCommand('perforce.diffRevision', diffRevision);
Expand Down Expand Up @@ -93,6 +94,21 @@ export namespace PerforceCommands
});
}

function deleteOpenFile() {
var editor = window.activeTextEditor;
if(!checkFileSelected()) {
return false;
}

if(!editor || !editor.document) {
return false;
}

revert();
var fileUri = editor.document.uri;
p4delete(fileUri);
}

export function p4delete(fileUri: Uri) {
const args = '"' + Utils.expansePath(fileUri.fsPath) + '"';
PerforceService.execute(fileUri, "delete", (err, stdout, stderr) => {
Expand Down

0 comments on commit c8c9165

Please sign in to comment.