Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected async doDiscard(repository: Repository, change: GitFileChange) {
// Allow deletion, only iff the same file is not yet in the Git index.
if (await this.git.lsFiles(repository, change.uri, { errorUnmatch: true })) {
if (await this.confirm(change.uri)) {
try {
await this.git.unstage(repository, change.uri, { treeish: 'HEAD', reset: 'working-tree' });
} catch (error) {
this.gitErrorHandler.handleError(error);
}
}
} else {
await this.commandService.executeCommand(WorkspaceCommands.FILE_DELETE.id, new URI(change.uri));
}
}
protected async doDiscard(repository: Repository, change: GitFileChange) {
// Allow deletion, only iff the same file is not yet in the Git index.
if (await this.git.lsFiles(repository, change.uri, { errorUnmatch: true })) {
if (await this.confirm(change.uri)) {
try {
await this.git.unstage(repository, change.uri, { treeish: 'HEAD', reset: 'working-tree' });
} catch (error) {
this.gitErrorHandler.handleError(error);
}
}
} else {
await this.commandService.executeCommand(WorkspaceCommands.FILE_DELETE.id, new URI(change.uri));
}
if (this.listContainer) {
this.listContainer.focus();
}
}
const { repository } = this;
const status = this.getStatus();
if (!(status && status.changes.some(change => change.uri === uri))) {
return;
}
// Allow deletion, only iff the same file is not yet in the Git index.
if (await this.git.lsFiles(repository, uri, { errorUnmatch: true })) {
if (await this.confirm(uri)) {
try {
await this.git.unstage(repository, uri, { treeish: 'HEAD', reset: 'working-tree' });
} catch (error) {
this.gitErrorHandler.handleError(error);
}
}
} else {
await this.commands.executeCommand(WorkspaceCommands.FILE_DELETE.id, new URI(uri));
}
}
registerKeybindings(registry: KeybindingRegistry): void {
super.registerKeybindings(registry);
registry.registerKeybinding({
command: FileNavigatorCommands.REVEAL_IN_NAVIGATOR.id,
keybinding: 'alt+r'
});
registry.registerKeybinding({
command: WorkspaceCommands.FILE_DELETE.id,
keybinding: 'del',
context: NavigatorKeybindingContexts.navigatorActive
});
if (isOSX) {
registry.registerKeybinding({
command: WorkspaceCommands.FILE_DELETE.id,
keybinding: 'cmd+backspace',
context: NavigatorKeybindingContexts.navigatorActive
});
}
registry.registerKeybinding({
command: WorkspaceCommands.FILE_RENAME.id,
keybinding: 'f2',
context: NavigatorKeybindingContexts.navigatorActive
});
registry.registerKeybinding({
command: FileNavigatorCommands.TOGGLE_HIDDEN_FILES.id,
keybinding: 'ctrlcmd+i',
context: NavigatorKeybindingContexts.navigatorActive
});
registerKeybindings(registry: KeybindingRegistry): void {
super.registerKeybindings(registry);
registry.registerKeybinding({
command: FileNavigatorCommands.REVEAL_IN_NAVIGATOR.id,
keybinding: 'alt+r'
});
registry.registerKeybinding({
command: WorkspaceCommands.FILE_DELETE.id,
keybinding: 'del',
context: NavigatorKeybindingContexts.navigatorActive
});
if (isOSX) {
registry.registerKeybinding({
command: WorkspaceCommands.FILE_DELETE.id,
keybinding: 'cmd+backspace',
context: NavigatorKeybindingContexts.navigatorActive
});
}
registry.registerKeybinding({
command: WorkspaceCommands.FILE_RENAME.id,
keybinding: 'f2',
context: NavigatorKeybindingContexts.navigatorActive
});