Skip to content

Commit

Permalink
Fixes eclipse-theia#5110, fixes eclipse-theia#5223: re-implemented "o…
Browse files Browse the repository at this point in the history
…pen source" to work with image/pdf files

Signed-off-by: fangnx <[email protected]>
  • Loading branch information
fangnx committed May 27, 2019
1 parent f39185a commit 56caaec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/core/src/browser/widget-open-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export interface WidgetOpenerOptions extends OpenerOptions {
* By default to the main area.
*/
widgetOptions?: ApplicationShell.WidgetOptions;
/**
* Specify what the widget is opened for
* 'preview': image/pdf/etc. preview
* 'edit': source file
*/
openFor?: 'preview' | 'edit';
}

@injectable()
Expand Down
4 changes: 4 additions & 0 deletions packages/editor/src/browser/editor-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export class EditorManager extends NavigatableWidgetOpenHandler<EditorWidget> {
}

canHandle(uri: URI, options?: WidgetOpenerOptions): number {
// Set the priority higher than image/pdf/etc. preview handlers if the editor is used to 'open source'
if (options && options.openFor === 'edit') {
return 110;
}
return 100;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ export class MiniBrowserOpenHandler extends NavigatableWidgetOpenHandler<MiniBro
const uri = this.getSourceUri(ref);
if (uri) {
await open(this.openerService, uri, {
widgetOptions: { ref, mode: 'open-to-left' }
widgetOptions: { ref, mode: 'open-to-left' },
openFor: 'edit'
});
}
}
Expand Down

0 comments on commit 56caaec

Please sign in to comment.