diff --git a/extensions/git/src/timelineProvider.ts b/extensions/git/src/timelineProvider.ts index bfedf9155c5..dd5a8ed708b 100644 --- a/extensions/git/src/timelineProvider.ts +++ b/extensions/git/src/timelineProvider.ts @@ -237,7 +237,7 @@ export class GitTimelineProvider implements TimelineProvider { private ensureProviderRegistration() { if (this.providerDisposable === undefined) { - this.providerDisposable = workspace.registerTimelineProvider(['file', 'git', 'vscode-remote', 'gitlens-git'], this); + this.providerDisposable = workspace.registerTimelineProvider(['file', 'git', 'vscode-remote', 'gitlens-git', 'vscode-local-history'], this); } } diff --git a/src/vs/workbench/contrib/localHistory/browser/localHistoryFileSystemProvider.ts b/src/vs/workbench/contrib/localHistory/browser/localHistoryFileSystemProvider.ts index 1c996df307f..367c04e72c5 100644 --- a/src/vs/workbench/contrib/localHistory/browser/localHistoryFileSystemProvider.ts +++ b/src/vs/workbench/contrib/localHistory/browser/localHistoryFileSystemProvider.ts @@ -9,7 +9,7 @@ import { URI } from 'vs/base/common/uri'; import { FileDeleteOptions, FileOverwriteOptions, FileSystemProviderCapabilities, FileType, FileWriteOptions, hasReadWriteCapability, IFileService, IFileSystemProvider, IFileSystemProviderWithFileReadWriteCapability, IStat, IWatchOptions } from 'vs/platform/files/common/files'; import { ResourceLabelFormatter, ResourceLabelFormatting } from 'vs/platform/label/common/label'; import { sep } from 'vs/base/common/path'; -import { basename, isEqual } from 'vs/base/common/resources'; +import { isEqual } from 'vs/base/common/resources'; import { VSBuffer } from 'vs/base/common/buffer'; interface ILocalHistoryResource { @@ -51,9 +51,12 @@ export class LocalHistoryFileSystemProvider implements IFileSystemProvider, IFil associatedResource: resource.associatedResource.toString(true) }; - return URI.from({ + // Try to preserve the associated resource as much as possible + // and only keep the `query` part dynamic. This enables other + // components (e.g. other timeline providers) to continue + // providing timeline entries even when our resource is active. + return resource.associatedResource.with({ scheme: LocalHistoryFileSystemProvider.SCHEMA, - path: `/${basename(resource.location)}`, query: JSON.stringify(serializedLocalHistoryResource) }); } diff --git a/src/vs/workbench/contrib/localHistory/browser/localHistoryTimeline.ts b/src/vs/workbench/contrib/localHistory/browser/localHistoryTimeline.ts index 3a465248a9e..fb6199c6614 100644 --- a/src/vs/workbench/contrib/localHistory/browser/localHistoryTimeline.ts +++ b/src/vs/workbench/contrib/localHistory/browser/localHistoryTimeline.ts @@ -22,6 +22,7 @@ import { ServicesAccessor } from 'vs/editor/browser/editorExtensions'; import { registerAction2, Action2, MenuId } from 'vs/platform/actions/common/actions'; import { isEqual } from 'vs/base/common/resources'; import { ICommandService } from 'vs/platform/commands/common/commands'; +import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; export class LocalHistoryTimeline extends Disposable implements IWorkbenchContribution, TimelineProvider { @@ -36,7 +37,7 @@ export class LocalHistoryTimeline extends Disposable implements IWorkbenchContri readonly label = localize('localHistory', "Local History"); - readonly scheme = [this.pathService.defaultUriScheme, LocalHistoryFileSystemProvider.SCHEMA]; + readonly scheme = '*'; // we try to show local history for all schemes if possible private readonly _onDidChange = this._register(new Emitter()); readonly onDidChange = this._onDidChange.event; @@ -46,7 +47,8 @@ export class LocalHistoryTimeline extends Disposable implements IWorkbenchContri @IWorkingCopyHistoryService private readonly workingCopyHistoryService: IWorkingCopyHistoryService, @IPathService private readonly pathService: IPathService, @IFileService private readonly fileService: IFileService, - @ILabelService private readonly labelService: ILabelService + @ILabelService private readonly labelService: ILabelService, + @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService ) { super(); @@ -126,11 +128,20 @@ export class LocalHistoryTimeline extends Disposable implements IWorkbenchContri // Make sure to support both default scheme and local history // scheme, in case the user is looking at a history entry. + + + // Try to convert the provided `uri` into a form that is likely + // for the provider to find entries for: + // - `vscode-local-history`: convert back to the associated resource + // - default-scheme: keep as is + // - anything else: convert let resource: URI; if (uri.scheme === LocalHistoryFileSystemProvider.SCHEMA) { resource = LocalHistoryFileSystemProvider.fromLocalHistoryFileSystem(uri).associatedResource; - } else { + } else if (uri.scheme === this.pathService.defaultUriScheme) { resource = uri; + } else { + resource = URI.from({ scheme: this.pathService.defaultUriScheme, authority: this.environmentService.remoteAuthority, path: uri.path }); } // Retrieve from working copy history