mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
git: editor actions
This commit is contained in:
parent
cce41b4869
commit
f2f937cf54
|
@ -33,12 +33,20 @@
|
|||
{
|
||||
"command": "git.openChange",
|
||||
"title": "%command.openChange%",
|
||||
"category": "Git"
|
||||
"category": "Git",
|
||||
"icon": {
|
||||
"light": "resources/icons/light/open-change.svg",
|
||||
"dark": "resources/icons/dark/open-change.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "git.openFile",
|
||||
"title": "%command.openFile%",
|
||||
"category": "Git"
|
||||
"category": "Git",
|
||||
"icon": {
|
||||
"light": "resources/icons/light/open-file.svg",
|
||||
"dark": "resources/icons/dark/open-file.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "git.stage",
|
||||
|
@ -368,6 +376,18 @@
|
|||
"when": "scmProvider == git && scmResourceGroup == workingTree",
|
||||
"group": "inline"
|
||||
}
|
||||
],
|
||||
"editor/title": [
|
||||
{
|
||||
"command": "git.openFile",
|
||||
"group": "navigation",
|
||||
"when": "isInDiffEditor"
|
||||
},
|
||||
{
|
||||
"command": "git.openChange",
|
||||
"group": "navigation",
|
||||
"when": "!isInDiffEditor"
|
||||
}
|
||||
]
|
||||
},
|
||||
"configuration": {
|
||||
|
|
1
extensions/git/resources/icons/dark/open-change.svg
Normal file
1
extensions/git/resources/icons/dark/open-change.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#C5C5C5" d="M15 4v6h-2.276c.113-.318.187-.653.226-1h1.05v-5h-2v-2h-4v2.051c-.347.038-.681.112-1 .225v-3.276h5l3 3zm-7 8.949v1.051h-6v-7h2.276c.126-.354.28-.693.485-1h-3.761v9h8v-2.051c-.166.02-.329.051-.5.051l-.5-.051z"/><path fill="#75BEFF" d="M12 8.5c0-1.933-1.567-3.5-3.5-3.5s-3.5 1.567-3.5 3.5 1.567 3.5 3.5 3.5c.711 0 1.369-.215 1.922-.578l3.578 3.578 1-1-3.578-3.578c.363-.553.578-1.211.578-1.922zm-3.5 2.5c-1.381 0-2.5-1.119-2.5-2.5s1.119-2.5 2.5-2.5 2.5 1.119 2.5 2.5-1.119 2.5-2.5 2.5z"/></svg>
|
After Width: | Height: | Size: 578 B |
1
extensions/git/resources/icons/dark/open-file.svg
Normal file
1
extensions/git/resources/icons/dark/open-file.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#C5C5C5" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/><polygon fill="#75BEFF" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/></svg>
|
After Width: | Height: | Size: 262 B |
1
extensions/git/resources/icons/light/open-change.svg
Normal file
1
extensions/git/resources/icons/light/open-change.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#656565" d="M15 4v6h-2.276c.113-.318.187-.653.226-1h1.05v-5h-2v-2h-4v2.051c-.347.038-.681.112-1 .225v-3.276h5l3 3zm-7 8.949v1.051h-6v-7h2.276c.126-.354.28-.693.485-1h-3.761v9h8v-2.051c-.166.02-.329.051-.5.051l-.5-.051z"/><path fill="#00539C" d="M12 8.5c0-1.933-1.567-3.5-3.5-3.5s-3.5 1.567-3.5 3.5 1.567 3.5 3.5 3.5c.711 0 1.369-.215 1.922-.578l3.578 3.578 1-1-3.578-3.578c.363-.553.578-1.211.578-1.922zm-3.5 2.5c-1.381 0-2.5-1.119-2.5-2.5s1.119-2.5 2.5-2.5 2.5 1.119 2.5 2.5-1.119 2.5-2.5 2.5z"/></svg>
|
After Width: | Height: | Size: 578 B |
3
extensions/git/resources/icons/light/open-file.svg
Normal file
3
extensions/git/resources/icons/light/open-file.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
|
||||
<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
|
||||
]><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#656565" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/><polygon fill="#00539C" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/></svg>
|
After Width: | Height: | Size: 419 B |
|
@ -108,17 +108,6 @@ export class CommandCenter {
|
|||
await this.model.status();
|
||||
}
|
||||
|
||||
@command('git.openChange')
|
||||
async openChange(uri: Uri): Promise<void> {
|
||||
const resource = resolveGitResource(uri);
|
||||
|
||||
if (!resource) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this.open(resource);
|
||||
}
|
||||
|
||||
async open(resource: Resource): Promise<void> {
|
||||
const left = this.getLeftResource(resource);
|
||||
const right = this.getRightResource(resource);
|
||||
|
@ -131,10 +120,10 @@ export class CommandCenter {
|
|||
return;
|
||||
}
|
||||
|
||||
return commands.executeCommand<void>('vscode.open', right);
|
||||
return await commands.executeCommand<void>('vscode.open', right);
|
||||
}
|
||||
|
||||
return commands.executeCommand<void>('vscode.diff', left, right, title);
|
||||
return await commands.executeCommand<void>('vscode.diff', left, right, title);
|
||||
}
|
||||
|
||||
private getLeftResource(resource: Resource): Uri | undefined {
|
||||
|
@ -192,13 +181,32 @@ export class CommandCenter {
|
|||
|
||||
@command('git.openFile')
|
||||
async openFile(uri: Uri): Promise<void> {
|
||||
const resource = resolveGitResource(uri);
|
||||
const scmResource = resolveGitResource(uri);
|
||||
|
||||
if (!resource) {
|
||||
return;
|
||||
if (scmResource) {
|
||||
return await commands.executeCommand<void>('vscode.open', scmResource.uri);
|
||||
}
|
||||
|
||||
return commands.executeCommand<void>('vscode.open', resource.uri);
|
||||
return await commands.executeCommand<void>('vscode.open', uri.with({ scheme: 'file' }));
|
||||
}
|
||||
|
||||
@command('git.openChange')
|
||||
async openChange(uri: Uri): Promise<void> {
|
||||
const scmResource = resolveGitResource(uri);
|
||||
|
||||
if (scmResource) {
|
||||
return await this.open(scmResource);
|
||||
}
|
||||
|
||||
if (uri.scheme === 'file') {
|
||||
const uriString = uri.toString();
|
||||
const resource = this.model.workingTreeGroup.resources.filter(r => r.uri.toString() === uriString)[0]
|
||||
|| this.model.indexGroup.resources.filter(r => r.uri.toString() === uriString)[0];
|
||||
|
||||
if (resource) {
|
||||
return await this.open(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@command('git.stage')
|
||||
|
|
|
@ -29,6 +29,7 @@ import { Position } from 'vs/editor/common/core/position';
|
|||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { InlineDecoration } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { IAddedAction } from 'vs/editor/common/commonCodeEditor';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
|
||||
interface IEditorDiffDecorations {
|
||||
decorations: editorCommon.IModelDeltaDecoration[];
|
||||
|
@ -213,7 +214,8 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
|
|||
) {
|
||||
super();
|
||||
this._editorWorkerService = editorWorkerService;
|
||||
this._contextKeyService = contextKeyService;
|
||||
this._contextKeyService = contextKeyService.createScoped(domElement);
|
||||
this._contextKeyService.createKey('isInDiffEditor', true);
|
||||
|
||||
this.id = (++DIFF_EDITOR_ID);
|
||||
|
||||
|
@ -289,8 +291,13 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
|
|||
|
||||
this._lineChanges = null;
|
||||
|
||||
this._createLeftHandSideEditor(options, instantiationService);
|
||||
this._createRightHandSideEditor(options, instantiationService);
|
||||
const services = new ServiceCollection();
|
||||
services.set(IContextKeyService, this._contextKeyService);
|
||||
|
||||
const scopedInstantiationService = instantiationService.createChild(services);
|
||||
|
||||
this._createLeftHandSideEditor(options, scopedInstantiationService);
|
||||
this._createRightHandSideEditor(options, scopedInstantiationService);
|
||||
|
||||
if (options.automaticLayout) {
|
||||
this._measureDomElementToken = window.setInterval(() => this._measureDomElement(false), 100);
|
||||
|
|
Loading…
Reference in a new issue