mirror of
https://github.com/coder/code-server.git
synced 2026-05-12 07:17:26 +02:00
Update to VS Code 1.52.1
This commit is contained in:
@@ -14,6 +14,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IOpener, IOpenerService, IValidator, IExternalUriResolver, OpenOptions, ResolveExternalUriOptions, IResolvedExternalUri, IExternalOpener, matchesScheme } from 'vs/platform/opener/common/opener';
|
||||
import { EditorOpenContext } from 'vs/platform/editor/common/editor';
|
||||
import { ResourceMap } from 'vs/base/common/map';
|
||||
|
||||
|
||||
class CommandOpener implements IOpener {
|
||||
@@ -74,7 +75,14 @@ class EditorOpener implements IOpener {
|
||||
}
|
||||
|
||||
await this._editorService.openCodeEditor(
|
||||
{ resource: target, options: { selection, context: options?.fromUserGesture ? EditorOpenContext.USER : EditorOpenContext.API } },
|
||||
{
|
||||
resource: target,
|
||||
options: {
|
||||
selection,
|
||||
context: options?.fromUserGesture ? EditorOpenContext.USER : EditorOpenContext.API,
|
||||
...options?.editorOptions
|
||||
}
|
||||
},
|
||||
this._editorService.getFocusedCodeEditor(),
|
||||
options?.openToSide
|
||||
);
|
||||
@@ -90,6 +98,7 @@ export class OpenerService implements IOpenerService {
|
||||
private readonly _openers = new LinkedList<IOpener>();
|
||||
private readonly _validators = new LinkedList<IValidator>();
|
||||
private readonly _resolvers = new LinkedList<IExternalUriResolver>();
|
||||
private readonly _resolvedUriTargets = new ResourceMap<URI>(uri => uri.with({ path: null, fragment: null, query: null }).toString());
|
||||
|
||||
private _externalOpener: IExternalOpener;
|
||||
|
||||
@@ -148,16 +157,18 @@ export class OpenerService implements IOpenerService {
|
||||
}
|
||||
|
||||
async open(target: URI | string, options?: OpenOptions): Promise<boolean> {
|
||||
|
||||
// check with contributed validators
|
||||
for (const validator of this._validators.toArray()) {
|
||||
if (!(await validator.shouldOpen(target))) {
|
||||
const targetURI = typeof target === 'string' ? URI.parse(target) : target;
|
||||
// validate against the original URI that this URI resolves to, if one exists
|
||||
const validationTarget = this._resolvedUriTargets.get(targetURI) ?? target;
|
||||
for (const validator of this._validators) {
|
||||
if (!(await validator.shouldOpen(validationTarget))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// check with contributed openers
|
||||
for (const opener of this._openers.toArray()) {
|
||||
for (const opener of this._openers) {
|
||||
const handled = await opener.open(target, options);
|
||||
if (handled) {
|
||||
return true;
|
||||
@@ -168,9 +179,10 @@ export class OpenerService implements IOpenerService {
|
||||
}
|
||||
|
||||
async resolveExternalUri(resource: URI, options?: ResolveExternalUriOptions): Promise<IResolvedExternalUri> {
|
||||
for (const resolver of this._resolvers.toArray()) {
|
||||
for (const resolver of this._resolvers) {
|
||||
const result = await resolver.resolveExternalUri(resource, options);
|
||||
if (result) {
|
||||
this._resolvedUriTargets.set(result.resolved, resource);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -180,7 +192,7 @@ export class OpenerService implements IOpenerService {
|
||||
|
||||
private async _doOpenExternal(resource: URI | string, options: OpenOptions | undefined): Promise<boolean> {
|
||||
|
||||
//todo@joh IExternalUriResolver should support `uri: URI | string`
|
||||
//todo@jrieken IExternalUriResolver should support `uri: URI | string`
|
||||
const uri = typeof resource === 'string' ? URI.parse(resource) : resource;
|
||||
const { resolved } = await this.resolveExternalUri(uri, options);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user