mirror of
https://github.com/Microsoft/vscode
synced 2024-09-18 01:58:27 +00:00
Only enable open external for resoruces when environment supports it
This commit is contained in:
parent
5fa4aad3c2
commit
39bdf95247
|
@ -19,6 +19,7 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
|
|||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
||||
export interface IOpenCallbacks {
|
||||
openInternal: (input: EditorInput, options: EditorOptions) => Promise<void>;
|
||||
|
@ -48,6 +49,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
|
|||
telemetryService: ITelemetryService,
|
||||
themeService: IThemeService,
|
||||
@ITextFileService private readonly textFileService: ITextFileService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@IStorageService storageService: IStorageService
|
||||
) {
|
||||
super(id, telemetryService, themeService, storageService);
|
||||
|
@ -93,8 +95,8 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
|
|||
this.binaryContainer,
|
||||
this.scrollbar,
|
||||
{
|
||||
openInternalClb: resource => this.handleOpenInternalCallback(input, options),
|
||||
openExternalClb: resource => this.callbacks.openExternal(resource),
|
||||
openInternalClb: _ => this.handleOpenInternalCallback(input, options),
|
||||
openExternalClb: this.environmentService.configuration.remoteAuthority ? undefined : resource => this.callbacks.openExternal(resource),
|
||||
metadataClb: meta => this.handleMetadataChanged(meta)
|
||||
}
|
||||
);
|
||||
|
|
|
@ -64,7 +64,7 @@ export interface ResourceViewerContext extends IDisposable {
|
|||
|
||||
interface ResourceViewerDelegate {
|
||||
openInternalClb(uri: URI): void;
|
||||
openExternalClb(uri: URI): void;
|
||||
openExternalClb?(uri: URI): void;
|
||||
metadataClb(meta: string): void;
|
||||
}
|
||||
|
||||
|
@ -166,12 +166,13 @@ class LargeImageView {
|
|||
label.textContent = nls.localize('largeImageError', "The image is not displayed in the editor because it is too large ({0}).", size);
|
||||
container.appendChild(label);
|
||||
|
||||
if (descriptor.resource.scheme === Schemas.file) {
|
||||
const openExternal = delegate.openExternalClb;
|
||||
if (descriptor.resource.scheme === Schemas.file && openExternal) {
|
||||
const link = DOM.append(label, DOM.$('a.embedded-link'));
|
||||
link.setAttribute('role', 'button');
|
||||
link.textContent = nls.localize('resourceOpenExternalButton', "Open image using external program?");
|
||||
|
||||
disposables.push(DOM.addDisposableListener(link, DOM.EventType.CLICK, () => delegate.openExternalClb(descriptor.resource)));
|
||||
disposables.push(DOM.addDisposableListener(link, DOM.EventType.CLICK, () => openExternal(descriptor.resource)));
|
||||
}
|
||||
|
||||
return combinedDisposable(disposables);
|
||||
|
|
|
@ -15,6 +15,7 @@ import { BINARY_FILE_EDITOR_ID } from 'vs/workbench/contrib/files/common/files';
|
|||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
||||
/**
|
||||
* An implementation of editor for binary files like images.
|
||||
|
@ -29,7 +30,8 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
|
|||
@IWindowsService private readonly windowsService: IWindowsService,
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
@ITextFileService textFileService: ITextFileService,
|
||||
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
|
||||
) {
|
||||
super(
|
||||
BinaryFileEditor.ID,
|
||||
|
@ -40,7 +42,8 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
|
|||
telemetryService,
|
||||
themeService,
|
||||
textFileService,
|
||||
storageService
|
||||
environmentService,
|
||||
storageService,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue