Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose diffEditor to plugins #1865

Closed
SamVerschueren opened this issue Jan 8, 2016 · 8 comments
Closed

Expose diffEditor to plugins #1865

SamVerschueren opened this issue Jan 8, 2016 · 8 comments
Assignees
Labels
api feature-request Request for new features or functionality
Milestone

Comments

@SamVerschueren
Copy link
Contributor

It would be nice to be able to open the diffEditor in a plugin. At the moment, I determine the diff myself in vscode-yo if a conflict arrises. But the diffEditor of Code is much more powerfull and shows the diffs very nicely. Is this a possibility?

// @bpasero

@bpasero bpasero added feature-request Request for new features or functionality api labels Jan 8, 2016
@bpasero bpasero added this to the Backlog milestone Jan 8, 2016
@bpasero
Copy link
Member

bpasero commented Jan 8, 2016

Yes, just talked about this with @jrieken

@jrieken
Copy link
Member

jrieken commented Apr 29, 2016

@bpasero Given virtual document etc and the API command, can't we just expose the underlying command?

@jrieken jrieken modified the milestones: May 2016, Backlog Apr 29, 2016
@bpasero
Copy link
Member

bpasero commented Apr 29, 2016

@jrieken the command I am using in the explorer currently only works with files that exists on disk (https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/files/browser/fileActions.ts#L1270). we would have to introduce a new command that can deal with any resource and then use it from that action too.

@jrieken
Copy link
Member

jrieken commented Apr 29, 2016

k. seems easy, let's do that in May

@jrieken jrieken self-assigned this Apr 29, 2016
@bpasero
Copy link
Member

bpasero commented May 2, 2016

Something like this seems to work already:

extHostApiComands

this._register('vscode.diff', (left: URI, right: URI, label: string) => {
    return this._commands.executeCommand('_workbench.diff', left, right, label);
}, {
    description: 'Opens the provided resources in the diff editor to compare their contents.',
    args: [
        { name: 'left', description: 'Uri of the resource for the left hand side of the diff editor', constraint: value => value instanceof URI },
        { name: 'right', description: 'Uri of the resource for the right hand side of the diff editor', constraint: value => value instanceof URI },
        { name: 'label', description: 'Label to use for the diff editor', constraint: value => typeof value === 'string' }
    ]
});

electron-browser/actions

KeybindingsRegistry.registerCommandDesc({
    id: '_workbench.diff',
    weight: KeybindingsRegistry.WEIGHT.workbenchContrib(0),
    handler(accessor: ServicesAccessor, args: [URI, URI, string]) {
        const instantiationService = accessor.get(IInstantiationService);
        const editorService = accessor.get(IWorkbenchEditorService);

        const left = instantiationService.createInstance(ResourceEditorInput, nls.localize('left', "Left"), null, args[0]);
        const right = instantiationService.createInstance(ResourceEditorInput, nls.localize('right', "Right"), null, args[1]);
        const diff = new DiffEditorInput(args[2], null, left, right);

        return editorService.openEditor(diff);
    },
    context: undefined,
    primary: undefined
});

@daviwil
Copy link
Contributor

daviwil commented May 23, 2016

If we provide a normal file URI to this API (not a virtual document URI) will it work as expected?

@rebornix
Copy link
Member

Good to see this newly added api then we may diff PR in VS Code.

@jrieken
Copy link
Member

jrieken commented May 24, 2016

@daviwil Yes file or virtual resources are all supported

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

5 participants