optionally show Open File action

fixes #41137
This commit is contained in:
Joao Moreno 2018-01-26 15:28:49 +01:00
parent 1dbb41ace2
commit 786ea020f7
3 changed files with 26 additions and 8 deletions

View file

@ -726,7 +726,7 @@
},
{
"command": "git.openFile2",
"when": "scmProvider == git && scmResourceGroup == merge",
"when": "scmProvider == git && scmResourceGroup == merge && config.git.showInlineOpenFileAction",
"group": "inline0"
},
{
@ -756,7 +756,7 @@
},
{
"command": "git.openFile2",
"when": "scmProvider == git && scmResourceGroup == index",
"when": "scmProvider == git && scmResourceGroup == index && config.git.showInlineOpenFileAction",
"group": "inline0"
},
{
@ -796,7 +796,7 @@
},
{
"command": "git.openFile2",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"when": "scmProvider == git && scmResourceGroup == workingTree && config.git.showInlineOpenFileAction",
"group": "inline0"
},
{
@ -941,6 +941,11 @@
"type": "boolean",
"default": false,
"description": "%config.promptToSaveFilesBeforeCommit%"
},
"git.showInlineOpenFileAction": {
"type": "boolean",
"default": true,
"description": "%config.showInlineOpenFileAction%"
}
}
},

View file

@ -65,10 +65,11 @@
"config.discardAllScope": "Controls what changes are discarded by the `Discard all changes` command. `all` discards all changes. `tracked` discards only tracked files. `prompt` shows a prompt dialog every time the action is run.",
"config.decorations.enabled": "Controls if Git contributes colors and badges to the explorer and the open editors view.",
"config.promptToSaveFilesBeforeCommit": "Controls whether Git should check for unsaved files before committing.",
"config.showInlineOpenFileAction": "Controls whether to show an inline Open File action in the Git changes view.",
"colors.modified": "Color for modified resources.",
"colors.deleted": "Color for deleted resources.",
"colors.untracked": "Color for untracked resources.",
"colors.ignored": "Color for ignored resources.",
"colors.conflict": "Color for resources with conflicts.",
"colors.submodule": "Color for submodule resources."
}
}

View file

@ -429,6 +429,7 @@ interface ResourceTemplate {
fileLabel: FileLabel;
decorationIcon: HTMLElement;
actionBar: ActionBar;
elementDisposable: IDisposable;
dispose: () => void;
}
@ -464,7 +465,8 @@ class ResourceRenderer implements IRenderer<ISCMResource, ResourceTemplate> {
private actionItemProvider: IActionItemProvider,
private getSelectedResources: () => ISCMResource[],
@IThemeService private themeService: IThemeService,
@IInstantiationService private instantiationService: IInstantiationService
@IInstantiationService private instantiationService: IInstantiationService,
@IConfigurationService private configurationService: IConfigurationService
) { }
renderTemplate(container: HTMLElement): ResourceTemplate {
@ -480,7 +482,7 @@ class ResourceRenderer implements IRenderer<ISCMResource, ResourceTemplate> {
const decorationIcon = append(element, $('.decoration-icon'));
return {
element, name, fileLabel, decorationIcon, actionBar, dispose: () => {
element, name, fileLabel, decorationIcon, actionBar, elementDisposable: EmptyDisposable, dispose: () => {
actionBar.dispose();
fileLabel.dispose();
}
@ -488,13 +490,22 @@ class ResourceRenderer implements IRenderer<ISCMResource, ResourceTemplate> {
}
renderElement(resource: ISCMResource, index: number, template: ResourceTemplate): void {
template.elementDisposable.dispose();
const theme = this.themeService.getTheme();
const icon = theme.type === LIGHT ? resource.decorations.icon : resource.decorations.iconDark;
template.fileLabel.setFile(resource.sourceUri, { fileDecorations: { colors: false, badges: !icon, data: resource.decorations } });
template.actionBar.clear();
template.actionBar.context = resource;
template.actionBar.push(this.scmMenus.getResourceActions(resource), { icon: true, label: false });
const updateActions = () => {
template.actionBar.clear();
template.actionBar.push(this.scmMenus.getResourceActions(resource), { icon: true, label: false });
};
template.elementDisposable = this.configurationService.onDidChangeConfiguration(updateActions);
updateActions();
toggleClass(template.name, 'strike-through', resource.decorations.strikeThrough);
toggleClass(template.element, 'faded', resource.decorations.faded);
@ -511,6 +522,7 @@ class ResourceRenderer implements IRenderer<ISCMResource, ResourceTemplate> {
}
disposeTemplate(template: ResourceTemplate): void {
template.elementDisposable.dispose();
template.dispose();
}
}