瀏覽代碼

Fixes CodeLens jumping on virtual files

main
Eric Amodio 2 年之前
父節點
當前提交
58c53b578d
共有 6 個文件被更改,包括 27 次插入6 次删除
  1. +4
    -0
      src/codelens/codeLensProvider.ts
  2. +1
    -1
      src/git/gitProviderService.ts
  3. +2
    -1
      src/git/gitUri.ts
  4. +13
    -2
      src/plus/github/githubGitProvider.ts
  5. +4
    -0
      src/system/utils.ts
  6. +3
    -2
      src/views/nodes/fileHistoryTrackerNode.ts

+ 4
- 0
src/codelens/codeLensProvider.ts 查看文件

@ -41,6 +41,7 @@ import { Logger } from '../logger';
import { asCommand, executeCoreCommand } from '../system/command';
import { is, once } from '../system/function';
import { filterMap, find, first, join, map } from '../system/iterable';
import { isVirtualUri } from '../system/utils';
export class GitRecentChangeCodeLens extends CodeLens {
constructor(
@ -106,6 +107,9 @@ export class GitCodeLensProvider implements CodeLensProvider {
}
async provideCodeLenses(document: TextDocument, token: CancellationToken): Promise<CodeLens[]> {
// Since we can't currently blame edited virtual documents, don't even attempt anything if dirty
if (document.isDirty && isVirtualUri(document.uri)) return [];
const trackedDocument = await this.container.tracker.getOrAdd(document);
if (!trackedDocument.isBlameable) return [];

+ 1
- 1
src/git/gitProviderService.ts 查看文件

@ -834,7 +834,7 @@ export class GitProviderService implements Disposable {
throw new ProviderNotFoundError(repoPath);
// let id = !isWeb ? GitProviderId.Git : undefined;
// if (typeof repoPath !== 'string' && repoPath.scheme === DocumentSchemes.Virtual) {
// if (typeof repoPath !== 'string' && repoPath.scheme === Schemes.Virtual) {
// if (repoPath.authority.startsWith('github')) {
// id = GitProviderId.GitHub;
// } else {

+ 2
- 1
src/git/gitUri.ts 查看文件

@ -10,6 +10,7 @@ import { memoize } from '../system/decorators/memoize';
import { formatPath } from '../system/formatPath';
import { basename, getBestPath, normalizePath, relativeDir, splitPath } from '../system/path';
// import { CharCode } from '../system/string';
import { isVirtualUri } from '../system/utils';
import type { RevisionUriData } from './gitProvider';
import { GitFile, GitRevision } from './models';
@ -83,7 +84,7 @@ export class GitUri extends (Uri as any as UriEx) {
return;
}
if (uri.scheme === Schemes.Virtual || uri.scheme === Schemes.GitHub) {
if (isVirtualUri(uri)) {
super(uri);
const [, owner, repo] = uri.path.split('/', 3);

+ 13
- 2
src/plus/github/githubGitProvider.ts 查看文件

@ -2369,8 +2369,19 @@ export class GitHubGitProvider implements GitProvider, Disposable {
return this.supportedSchemes.has(uri.scheme);
}
isTracked(uri: Uri): Promise<boolean> {
return Promise.resolve(this.isTrackable(uri) && this.container.git.getRepository(uri) != null);
async isTracked(uri: Uri): Promise<boolean> {
if (!this.isTrackable(uri) || this.container.git.getRepository(uri) == null) return false;
// Don't call out to RemoteHub to keep things more performant, since we only work with GitHub here
// const remotehub = await this.ensureRemoteHubApi();
// if (remotehub == null) return false;
// const providerUri = remotehub.getProviderUri(uri);
// if (providerUri == null) return false;
const providerUri = uri.with({ scheme: Schemes.GitHub });
const stats = await workspace.fs.stat(providerUri);
return stats != null;
}
@log()

+ 4
- 0
src/system/utils.ts 查看文件

@ -71,6 +71,10 @@ export function isActiveDocument(document: TextDocument): boolean {
return editor != null && editor.document === document;
}
export function isVirtualUri(uri: Uri): boolean {
return uri.scheme === Schemes.Virtual || uri.scheme === Schemes.GitHub;
}
export function isVisibleDocument(document: TextDocument): boolean {
if (window.visibleTextEditors.length === 0) return false;

+ 3
- 2
src/views/nodes/fileHistoryTrackerNode.ts 查看文件

@ -1,6 +1,6 @@
import { Disposable, FileType, TextEditor, TreeItem, TreeItemCollapsibleState, window, workspace } from 'vscode';
import { UriComparer } from '../../comparers';
import { ContextKeys, Schemes } from '../../constants';
import { ContextKeys } from '../../constants';
import { setContext } from '../../context';
import { GitCommitish, GitUri } from '../../git/gitUri';
import { GitReference, GitRevision } from '../../git/models';
@ -9,6 +9,7 @@ import { ReferencePicker } from '../../quickpicks/referencePicker';
import { gate } from '../../system/decorators/gate';
import { debug, log } from '../../system/decorators/log';
import { debounce, Deferrable } from '../../system/function';
import { isVirtualUri } from '../../system/utils';
import { FileHistoryView } from '../fileHistoryView';
import { FileHistoryNode } from './fileHistoryNode';
import { ContextValues, SubscribeableViewNode, ViewNode } from './viewNode';
@ -239,7 +240,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
// If we are losing the active editor, give more time before assuming its really gone
// For virtual repositories the active editor event takes a while to fire
// Ultimately we need to be using the upcoming Tabs api to avoid this
if (editor == null && (this._uri?.scheme === Schemes.Virtual || this._uri?.scheme === Schemes.GitHub)) {
if (editor == null && isVirtualUri(this._uri)) {
if (this._triggerChangeDebounced == null) {
this._triggerChangeDebounced = debounce(() => this.triggerChange(), 1500);
}

Loading…
取消
儲存