diff --git a/src/vs/editor/browser/standalone/standaloneEditor.ts b/src/vs/editor/browser/standalone/standaloneEditor.ts index 8ffd713d0d7..f99c9ed5634 100644 --- a/src/vs/editor/browser/standalone/standaloneEditor.ts +++ b/src/vs/editor/browser/standalone/standaloneEditor.ts @@ -18,6 +18,7 @@ import {TPromise} from 'vs/base/common/winjs.base'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection'; import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService'; +import {OpenerService} from 'vs/platform/opener/browser/openerService'; import {IModel} from 'vs/editor/common/editorCommon'; import {IModelService} from 'vs/editor/common/services/modelService'; import {Colorizer, IColorizerElementOptions, IColorizerOptions} from 'vs/editor/browser/standalone/colorizer'; @@ -61,6 +62,10 @@ export function create(domElement:HTMLElement, options?:IEditorConstructionOptio services.editorService = editorService; } + if (!services.openerService) { + services.openerService = new OpenerService(editorService, services.commandService); + } + var t = prepareServices(domElement, services); var result = t.ctx.instantiationService.createInstance(StandaloneEditor, domElement, options, t.toDispose); diff --git a/src/vs/editor/browser/standalone/standaloneServices.ts b/src/vs/editor/browser/standalone/standaloneServices.ts index 56b322a27b0..a312ef552a7 100644 --- a/src/vs/editor/browser/standalone/standaloneServices.ts +++ b/src/vs/editor/browser/standalone/standaloneServices.ts @@ -19,6 +19,7 @@ import {InstantiationService} from 'vs/platform/instantiation/common/instantiati import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection'; import {ICommandService} from 'vs/platform/commands/common/commands'; import {CommandService} from 'vs/platform/commands/common/commandService'; +import {IOpenerService} from 'vs/platform/opener/common/opener'; import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; import {MarkerService} from 'vs/platform/markers/common/markerService'; import {IMarkerService} from 'vs/platform/markers/common/markers'; @@ -84,6 +85,10 @@ export interface IEditorOverrideServices { * @internal */ commandService?:ICommandService; + /** + * @internal + */ + openerService?:IOpenerService; /** * @internal */ diff --git a/src/vs/editor/contrib/links/browser/links.ts b/src/vs/editor/contrib/links/browser/links.ts index 2510a7ae3ec..26e46e5bceb 100644 --- a/src/vs/editor/contrib/links/browser/links.ts +++ b/src/vs/editor/contrib/links/browser/links.ts @@ -14,8 +14,8 @@ import Severity from 'vs/base/common/severity'; import URI from 'vs/base/common/uri'; import {TPromise} from 'vs/base/common/winjs.base'; import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent'; -import {IEditorService, IResourceInput} from 'vs/platform/editor/common/editor'; import {IMessageService} from 'vs/platform/message/common/message'; +import {IOpenerService} from 'vs/platform/opener/common/opener'; import {EditorAction} from 'vs/editor/common/editorAction'; import {Behaviour} from 'vs/editor/common/editorActionEnablement'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -94,19 +94,19 @@ class LinkDetector implements editorCommon.IEditorContribution { private computePromise:TPromise; private activeLinkDecorationId:string; private lastMouseEvent:IEditorMouseEvent; - private editorService:IEditorService; + private openerService:IOpenerService; private messageService:IMessageService; private editorWorkerService: IEditorWorkerService; private currentOccurences:{ [decorationId:string]:LinkOccurence; }; constructor( editor:ICodeEditor, - @IEditorService editorService:IEditorService, + @IOpenerService openerService:IOpenerService, @IMessageService messageService:IMessageService, @IEditorWorkerService editorWorkerService: IEditorWorkerService ) { this.editor = editor; - this.editorService = editorService; + this.openerService = openerService; this.messageService = messageService; this.editorWorkerService = editorWorkerService; this.listenersToRemove = []; @@ -253,54 +253,22 @@ class LinkDetector implements editorCommon.IEditorContribution { this.openLinkOccurence(occurence, mouseEvent.event.altKey); } - public openLinkOccurence(occurence:LinkOccurence, openToSide:boolean):void { + public openLinkOccurence(occurence: LinkOccurence, openToSide: boolean): void { - if (!this.editorService) { + if (!this.openerService) { return; } - var link = occurence.link; - var absoluteUrl = link.url; - var hashIndex = absoluteUrl.indexOf('#'); - var lineNumber = -1; - var column = -1; - if (hashIndex >= 0) { - var hash = absoluteUrl.substr(hashIndex + 1); - var selection = hash.split(','); - - if (selection.length > 0) { - lineNumber = Number(selection[0]); - } - - if (selection.length > 1) { - column = Number(selection[1]); - } - - if (lineNumber >= 0 || column >= 0) { - absoluteUrl = absoluteUrl.substr(0, hashIndex); - } - } - - var url: URI; + let url: URI; try { - url = URI.parse(absoluteUrl); + url = URI.parse(occurence.link.url); } catch (err) { // invalid url - this.messageService.show(Severity.Warning, nls.localize('invalid.url', 'Invalid URI: cannot open {0}', absoluteUrl)); + this.messageService.show(Severity.Warning, nls.localize('invalid.url', 'Invalid URI: cannot open {0}', occurence.link.url)); return; } - var input:IResourceInput = { - resource: url - }; - - if (lineNumber >= 0) { - input.options = { - selection: { startLineNumber: lineNumber, startColumn: column } - }; - } - - this.editorService.openEditor(input, openToSide).done(null, onUnexpectedError); + this.openerService.open(url, { openToSide }).done(null, onUnexpectedError); } public getLinkOccurence(position: editorCommon.IPosition): LinkOccurence {