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

Prototyping custom editors #77789

Merged
merged 25 commits into from
Sep 11, 2019
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b104d8c
Custom Editor exploration
mjbvz Jul 22, 2019
0c173e5
Re-use existing custom editor if one is already open
mjbvz Aug 22, 2019
39a8864
Don't re-create custom editor webview when clicking on already visibl…
mjbvz Aug 22, 2019
8984b20
Move customEditorInput to own file
mjbvz Aug 22, 2019
30fbe75
First draft of serializing custom editor inputs
mjbvz Aug 22, 2019
f526d68
Use glob patterns instead of simple file extensions for matching cust…
mjbvz Aug 22, 2019
35dbd18
Add descriptions
mjbvz Aug 22, 2019
f013ea1
Try opening standard editor while prompting for custom editor
mjbvz Aug 22, 2019
cf3976d
Make sure we hide image status on dispose
mjbvz Aug 22, 2019
906fcc0
Make sure we restore editor group too
mjbvz Aug 22, 2019
ac6c1d5
Use glob patterns for workbench.editor.custom
mjbvz Aug 22, 2019
139cd4c
Allow users to configure custom editors for additional file types
mjbvz Aug 24, 2019
88730af
Use filename glob instead of glob on full resource path
mjbvz Aug 25, 2019
2c20c92
Adding placeholder for prompt open with
mjbvz Aug 25, 2019
e9979ee
Add enableByDefault setting for editor contributions
mjbvz Aug 26, 2019
76cb0a8
Enable custom editors by default and add `discretion` enum
mjbvz Sep 10, 2019
23ee5c7
Allow custom editors to specify both a scheme and filenamePattern the…
mjbvz Sep 10, 2019
e2beea2
Rework custom editor setting
mjbvz Sep 10, 2019
41cef87
Don't allow custom editors to be enabled for all resources by a confi…
mjbvz Sep 10, 2019
665eead
Replace built-in image editor with one from extension
mjbvz Sep 10, 2019
a2da763
Adding reopen with command
mjbvz Sep 10, 2019
b77afb3
Improve comment
mjbvz Sep 10, 2019
d90708f
Remove commented code
mjbvz Sep 11, 2019
3d269db
Localize package.json and remove image
mjbvz Sep 11, 2019
d09659b
Remove extra lib setting from tsconfig
mjbvz Sep 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding placeholder for prompt open with
  • Loading branch information
mjbvz committed Sep 11, 2019
commit 2c20c92be8b4a84491080e46cd0c34edd6d3887e
19 changes: 11 additions & 8 deletions src/vs/workbench/contrib/customEditor/browser/customEditors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as nls from 'vs/nls';
import * as glob from 'vs/base/common/glob';
import { UnownedDisposable } from 'vs/base/common/lifecycle';
import { basename } from 'vs/base/common/resources';
Expand All @@ -18,7 +19,6 @@ import { IEditor, IEditorInput } from 'vs/workbench/common/editor';
import { webviewEditorsExtensionPoint } from 'vs/workbench/contrib/customEditor/browser/extensionPoint';
import { CustomEditorInfo, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
import { TEXT_FILE_EDITOR_ID } from 'vs/workbench/contrib/files/common/files';
import { IWebviewService } from 'vs/workbench/contrib/webview/browser/webview';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService, IOpenEditorOverride } from 'vs/workbench/services/editor/common/editorService';
Expand Down Expand Up @@ -59,24 +59,27 @@ export class CustomEditorService implements ICustomEditorService {
group?: IEditorGroup,
): Promise<IEditor | undefined> {
const preferredEditors = await this.getCustomEditorsForResource(resource);
const defaultEditorId = 'default';
const pick = await this.quickInputService.pick([
{
label: 'Text',
id: TEXT_FILE_EDITOR_ID,
label: nls.localize('promptOpenWith.defaultEditor', "Default built-in editor"),
id: defaultEditorId,
},
...preferredEditors.map((editorDescriptor): IQuickPickItem => ({
label: editorDescriptor.displayName,
id: editorDescriptor.id
id: editorDescriptor.id,
}))
], {});
], {
placeHolder: nls.localize('promptOpenWith.placeHolder', "Select editor to use for '{0}'...", basename(resource)),
});

if (!pick) {
return;
}

if (pick.id === TEXT_FILE_EDITOR_ID) {
const editor = this.instantiationService.createInstance(FileEditorInput, resource, undefined, undefined);
return this.editorService.openEditor(editor, options, group);
if (pick.id === defaultEditorId) {
const fileInput = this.instantiationService.createInstance(FileEditorInput, resource, undefined, undefined);
return this.editorService.openEditor(fileInput, { ...options, ignoreOverrides: true }, group);
} else {
return this.openWith(resource, pick.id!, options, group);
}
Expand Down