Browse Source

Forces cache refresh on history refresh button

main
Eric Amodio 2 years ago
parent
commit
10b9f2e209
10 changed files with 206 additions and 125 deletions
  1. +24
    -23
      src/env/node/git/localGitProvider.ts
  2. +1
    -0
      src/git/gitProvider.ts
  3. +4
    -3
      src/git/gitProviderService.ts
  4. +21
    -18
      src/premium/github/githubGitProvider.ts
  5. +66
    -73
      src/trackers/documentTracker.ts
  6. +80
    -6
      src/trackers/gitDocumentTracker.ts
  7. +1
    -1
      src/views/nodes/fileHistoryNode.ts
  8. +4
    -0
      src/views/nodes/fileHistoryTrackerNode.ts
  9. +1
    -1
      src/views/nodes/lineHistoryNode.ts
  10. +4
    -0
      src/views/nodes/lineHistoryTrackerNode.ts

+ 24
- 23
src/env/node/git/localGitProvider.ts View File

@ -913,7 +913,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const doc = await this.container.tracker.getOrAdd(uri);
if (this.useCaching) {
if (doc.state != null) {
const cachedBlame = doc.state.get<CachedBlame>(key);
const cachedBlame = doc.state.getBlame(key);
if (cachedBlame != null) {
Logger.debug(cc, `Cache hit: '${key}'`);
return cachedBlame.item;
@ -935,7 +935,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const value: CachedBlame = {
item: promise as Promise<GitBlame>,
};
doc.state.set<CachedBlame>(key, value);
doc.state.setBlame(key, value);
}
return promise;
@ -972,7 +972,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
item: emptyPromise as Promise<GitBlame>,
errorMessage: msg,
};
document.state.set<CachedBlame>(key, value);
document.state.setBlame(key, value);
document.setBlameFailure();
@ -992,7 +992,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const doc = await this.container.tracker.getOrAdd(uri);
if (this.useCaching) {
if (doc.state != null) {
const cachedBlame = doc.state.get<CachedBlame>(key);
const cachedBlame = doc.state.getBlame(key);
if (cachedBlame != null) {
Logger.debug(cc, `Cache hit: ${key}`);
return cachedBlame.item;
@ -1014,7 +1014,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const value: CachedBlame = {
item: promise as Promise<GitBlame>,
};
doc.state.set<CachedBlame>(key, value);
doc.state.setBlame(key, value);
}
return promise;
@ -1053,7 +1053,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
item: emptyPromise as Promise<GitBlame>,
errorMessage: msg,
};
document.state.set<CachedBlame>(key, value);
document.state.setBlame(key, value);
document.setBlameFailure();
return emptyPromise as Promise<GitBlame>;
@ -1580,7 +1580,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const doc = await this.container.tracker.getOrAdd(uri);
if (this.useCaching) {
if (doc.state != null) {
const cachedDiff = doc.state.get<CachedDiff>(key);
const cachedDiff = doc.state.getDiff(key);
if (cachedDiff != null) {
Logger.debug(cc, `Cache hit: '${key}'`);
return cachedDiff.item;
@ -1611,7 +1611,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const value: CachedDiff = {
item: promise as Promise<GitDiff>,
};
doc.state.set<CachedDiff>(key, value);
doc.state.setDiff(key, value);
}
return promise;
@ -1651,7 +1651,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
item: emptyPromise as Promise<GitDiff>,
errorMessage: msg,
};
document.state.set<CachedDiff>(key, value);
document.state.setDiff(key, value);
return emptyPromise as Promise<GitDiff>;
}
@ -1669,7 +1669,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const doc = await this.container.tracker.getOrAdd(uri);
if (this.useCaching) {
if (doc.state != null) {
const cachedDiff = doc.state.get<CachedDiff>(key);
const cachedDiff = doc.state.getDiff(key);
if (cachedDiff != null) {
Logger.debug(cc, `Cache hit: ${key}`);
return cachedDiff.item;
@ -1700,7 +1700,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const value: CachedDiff = {
item: promise as Promise<GitDiff>,
};
doc.state.set<CachedDiff>(key, value);
doc.state.setDiff(key, value);
}
return promise;
@ -1737,7 +1737,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
item: emptyPromise as Promise<GitDiff>,
errorMessage: msg,
};
document.state.set<CachedDiff>(key, value);
document.state.setDiff(key, value);
return emptyPromise as Promise<GitDiff>;
}
@ -2159,10 +2159,11 @@ export class LocalGitProvider implements GitProvider, Disposable {
@log()
async getLogForFile(
repoPath: string | undefined,
fileName: string,
path: string,
options?: {
all?: boolean;
cursor?: string;
force?: boolean | undefined;
limit?: number;
ordering?: string | null;
range?: Range;
@ -2173,8 +2174,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
skip?: number;
},
): Promise<GitLog | undefined> {
if (repoPath != null && repoPath === normalizePath(fileName)) {
throw new Error(`File name cannot match the repository path; fileName=${fileName}`);
if (repoPath != null && repoPath === normalizePath(path)) {
throw new Error(`File name cannot match the repository path; fileName=${path}`);
}
const cc = Logger.getCorrelationContext();
@ -2218,10 +2219,10 @@ export class LocalGitProvider implements GitProvider, Disposable {
key += `:skip${options.skip}`;
}
const doc = await this.container.tracker.getOrAdd(GitUri.fromFile(fileName, repoPath!, options.ref));
if (this.useCaching && options.range == null) {
const doc = await this.container.tracker.getOrAdd(GitUri.fromFile(path, repoPath!, options.ref));
if (!options.force && this.useCaching && options.range == null) {
if (doc.state != null) {
const cachedLog = doc.state.get<CachedLog>(key);
const cachedLog = doc.state.getLog(key);
if (cachedLog != null) {
Logger.debug(cc, `Cache hit: '${key}'`);
return cachedLog.item;
@ -2229,7 +2230,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
if (options.ref != null || options.limit != null) {
// Since we are looking for partial log, see if we have the log of the whole file
const cachedLog = doc.state.get<CachedLog>(
const cachedLog = doc.state.getLog(
`log${options.renames ? ':follow' : ''}${options.reverse ? ':reverse' : ''}`,
);
if (cachedLog != null) {
@ -2275,7 +2276,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
commits: commits,
authors: authors,
query: (limit: number | undefined) =>
this.getLogForFile(repoPath, fileName, { ...opts, limit: limit }),
this.getLogForFile(repoPath, path, { ...opts, limit: limit }),
};
return log;
@ -2291,7 +2292,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
}
const promise = this.getLogForFileCore(repoPath, fileName, options, doc, key, cc);
const promise = this.getLogForFileCore(repoPath, path, options, doc, key, cc);
if (doc.state != null && options.range == null) {
Logger.debug(cc, `Cache add: '${key}'`);
@ -2299,7 +2300,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const value: CachedLog = {
item: promise as Promise<GitLog>,
};
doc.state.set<CachedLog>(key, value);
doc.state.setLog(key, value);
}
return promise;
@ -2381,7 +2382,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
item: emptyPromise as Promise<GitLog>,
errorMessage: msg,
};
document.state.set<CachedLog>(key, value);
document.state.setLog(key, value);
return emptyPromise as Promise<GitLog>;
}

+ 1
- 0
src/git/gitProvider.ts View File

@ -271,6 +271,7 @@ export interface GitProvider extends Disposable {
options?: {
all?: boolean | undefined;
cursor?: string | undefined;
force?: boolean | undefined;
limit?: number | undefined;
ordering?: string | null | undefined;
range?: Range | undefined;

+ 4
- 3
src/git/gitProviderService.ts View File

@ -1227,9 +1227,10 @@ export class GitProviderService implements Disposable {
@log()
async getLogForFile(
repoPath: string | Uri | undefined,
fileName: string,
path: string,
options?: {
all?: boolean;
force?: boolean;
limit?: number;
ordering?: string | null;
range?: Range;
@ -1242,8 +1243,8 @@ export class GitProviderService implements Disposable {
): Promise<GitLog | undefined> {
if (repoPath == null) return undefined;
const { provider, path } = this.getProvider(repoPath);
return provider.getLogForFile(path, fileName, options);
const { provider, path: rp } = this.getProvider(repoPath);
return provider.getLogForFile(rp, path, options);
}
@log()

+ 21
- 18
src/premium/github/githubGitProvider.ts View File

@ -73,7 +73,9 @@ import { RemoteProviderFactory, RemoteProviders } from '../../git/remotes/factor
import { RemoteProvider, RichRemoteProvider } from '../../git/remotes/provider';
import { SearchPattern } from '../../git/search';
import { LogCorrelationContext, Logger } from '../../logger';
import { debug, gate, Iterables, log } from '../../system';
import { gate } from '../../system/decorators/gate';
import { debug, log } from '../../system/decorators/log';
import { filterMap, some } from '../../system/iterable';
import { isAbsolute, isFolderGlob, maybeUri, normalizePath, relative } from '../../system/path';
import { CharCode } from '../../system/string';
import { CachedBlame, CachedLog, GitDocumentState } from '../../trackers/gitDocumentTracker';
@ -336,7 +338,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
const doc = await this.container.tracker.getOrAdd(uri);
if (doc.state != null) {
const cachedBlame = doc.state.get<CachedBlame>(key);
const cachedBlame = doc.state.getBlame(key);
if (cachedBlame != null) {
Logger.debug(cc, `Cache hit: '${key}'`);
return cachedBlame.item;
@ -357,7 +359,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
const value: CachedBlame = {
item: promise as Promise<GitBlame>,
};
doc.state.set<CachedBlame>(key, value);
doc.state.setBlame(key, value);
}
return promise;
@ -460,7 +462,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
item: emptyPromise as Promise<GitBlame>,
errorMessage: msg,
};
document.state.set<CachedBlame>(key, value);
document.state.setBlame(key, value);
document.setBlameFailure();
@ -1053,7 +1055,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
const moreUntil = limit != null && typeof limit === 'object' ? limit.until : undefined;
let moreLimit = typeof limit === 'number' ? limit : undefined;
if (moreUntil && Iterables.some(log.commits.values(), c => c.ref === moreUntil)) {
if (moreUntil && some(log.commits.values(), c => c.ref === moreUntil)) {
return log;
}
@ -1131,10 +1133,11 @@ export class GitHubGitProvider implements GitProvider, Disposable {
@log()
async getLogForFile(
repoPath: string | undefined,
fileName: string,
path: string,
options?: {
all?: boolean;
cursor?: string;
force?: boolean | undefined;
limit?: number;
ordering?: string | null;
range?: Range;
@ -1145,8 +1148,8 @@ export class GitHubGitProvider implements GitProvider, Disposable {
skip?: number;
},
): Promise<GitLog | undefined> {
if (repoPath != null && repoPath === normalizePath(fileName)) {
throw new Error(`File name cannot match the repository path; fileName=${fileName}`);
if (repoPath != null && repoPath === normalizePath(path)) {
throw new Error(`File name cannot match the repository path; fileName=${path}`);
}
const cc = Logger.getCorrelationContext();
@ -1190,10 +1193,10 @@ export class GitHubGitProvider implements GitProvider, Disposable {
key += `:skip${options.skip}`;
}
const doc = await this.container.tracker.getOrAdd(GitUri.fromFile(fileName, repoPath!, options.ref));
if (options.range == null) {
const doc = await this.container.tracker.getOrAdd(GitUri.fromFile(path, repoPath!, options.ref));
if (!options.force && options.range == null) {
if (doc.state != null) {
const cachedLog = doc.state.get<CachedLog>(key);
const cachedLog = doc.state.getLog(key);
if (cachedLog != null) {
Logger.debug(cc, `Cache hit: '${key}'`);
return cachedLog.item;
@ -1201,7 +1204,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
if (options.ref != null || options.limit != null) {
// Since we are looking for partial log, see if we have the log of the whole file
const cachedLog = doc.state.get<CachedLog>(
const cachedLog = doc.state.getLog(
`log${options.renames ? ':follow' : ''}${options.reverse ? ':reverse' : ''}`,
);
if (cachedLog != null) {
@ -1220,7 +1223,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
let i = 0;
const authors = new Map<string, GitAuthor>();
const commits = new Map(
Iterables.filterMap<[string, GitLogCommit], [string, GitLogCommit]>(
filterMap<[string, GitLogCommit], [string, GitLogCommit]>(
log.commits.entries(),
([ref, c]) => {
if (skip) {
@ -1247,7 +1250,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
commits: commits,
authors: authors,
query: (limit: number | undefined) =>
this.getLogForFile(repoPath, fileName, { ...opts, limit: limit }),
this.getLogForFile(repoPath, path, { ...opts, limit: limit }),
};
return log;
@ -1263,7 +1266,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
}
}
const promise = this.getLogForFileCore(repoPath, fileName, doc, key, cc, options);
const promise = this.getLogForFileCore(repoPath, path, doc, key, cc, options);
if (doc.state != null && options.range == null) {
Logger.debug(cc, `Cache add: '${key}'`);
@ -1271,7 +1274,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
const value: CachedLog = {
item: promise as Promise<GitLog>,
};
doc.state.set<CachedLog>(key, value);
doc.state.setLog(key, value);
}
return promise;
@ -1397,7 +1400,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
item: emptyPromise as Promise<GitLog>,
errorMessage: msg,
};
document.state.set<CachedLog>(key, value);
document.state.setLog(key, value);
return emptyPromise as Promise<GitLog>;
}
@ -1423,7 +1426,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
const moreUntil = limit != null && typeof limit === 'object' ? limit.until : undefined;
let moreLimit = typeof limit === 'number' ? limit : undefined;
if (moreUntil && Iterables.some(log.commits.values(), c => c.ref === moreUntil)) {
if (moreUntil && some(log.commits.values(), c => c.ref === moreUntil)) {
return log;
}

+ 66
- 73
src/trackers/documentTracker.ts View File

@ -69,7 +69,7 @@ export class DocumentTracker implements Disposable {
private _dirtyIdleTriggerDelay: number;
private readonly _disposable: Disposable;
// TODO@eamodio: replace with a trie?
private readonly _documentMap = new Map<TextDocument | string, Promise<TrackedDocument<T>>>();
protected readonly _documentMap = new Map<TextDocument | string, Promise<TrackedDocument<T>>>();
constructor(protected readonly container: Container) {
this._disposable = Disposable.from(
@ -232,102 +232,42 @@ export class DocumentTracker implements Disposable {
add(document: TextDocument): Promise<TrackedDocument<T>>;
add(uri: Uri): Promise<TrackedDocument<T>>;
add(documentOrId: TextDocument | Uri): Promise<TrackedDocument<T>> {
const doc = this._add(documentOrId);
return doc;
}
async clear() {
for (const d of this._documentMap.values()) {
(await d).dispose();
}
this._documentMap.clear();
}
get(fileName: string): Promise<TrackedDocument<T>> | undefined;
get(document: TextDocument): Promise<TrackedDocument<T>> | undefined;
get(uri: Uri): Promise<TrackedDocument<T>> | undefined;
get(documentOrId: string | TextDocument | Uri): Promise<TrackedDocument<T>> | undefined {
const doc = this._get(documentOrId);
return doc;
}
async getOrAdd(document: TextDocument): Promise<TrackedDocument<T>>;
async getOrAdd(uri: Uri): Promise<TrackedDocument<T>>;
async getOrAdd(documentOrId: TextDocument | Uri): Promise<TrackedDocument<T>> {
const doc = this._get(documentOrId) ?? this._add(documentOrId);
return doc;
}
has(fileName: string): boolean;
has(document: TextDocument): boolean;
has(uri: Uri): boolean;
has(key: string | TextDocument | Uri): boolean {
if (typeof key === 'string' || key instanceof Uri) {
key = GitUri.toKey(key);
}
return this._documentMap.has(key);
}
private async remove(document: TextDocument, tracked?: TrackedDocument<T>): Promise<void> {
let promise;
if (tracked != null) {
promise = this._documentMap.get(document);
}
this._documentMap.delete(document);
this._documentMap.delete(GitUri.toKey(document.uri));
(tracked ?? (await promise))?.dispose();
}
private async _add(documentOrId: TextDocument | Uri): Promise<TrackedDocument<T>> {
add(documentOrUri: TextDocument | Uri): Promise<TrackedDocument<T>>;
async add(documentOrUri: TextDocument | Uri): Promise<TrackedDocument<T>> {
let document;
if (GitUri.is(documentOrId)) {
if (GitUri.is(documentOrUri)) {
try {
document = await workspace.openTextDocument(documentOrId.documentUri());
document = await workspace.openTextDocument(documentOrUri.documentUri());
} catch (ex) {
const msg: string = ex?.toString() ?? '';
if (msg.includes('File seems to be binary and cannot be opened as text')) {
document = new BinaryTextDocument(documentOrId);
document = new BinaryTextDocument(documentOrUri);
} else if (
msg.includes('File not found') ||
msg.includes('Unable to read file') ||
msg.includes('Unable to resolve non-existing file')
) {
// If we can't find the file, assume it is because the file has been renamed or deleted at some point
document = new MissingRevisionTextDocument(documentOrId);
document = new MissingRevisionTextDocument(documentOrUri);
// const [fileName, repoPath] = await this.container.git.findWorkingFileName(documentOrId, undefined, ref);
// if (fileName == null) throw new Error(`Failed to add tracking for document: ${documentOrId}`);
// const [fileName, repoPath] = await this.container.git.findWorkingFileName(documentOrUri, undefined, ref);
// if (fileName == null) throw new Error(`Failed to add tracking for document: ${documentOrUri}`);
// documentOrId = await workspace.openTextDocument(path.resolve(repoPath!, fileName));
// documentOrUri = await workspace.openTextDocument(path.resolve(repoPath!, fileName));
} else {
throw ex;
}
}
} else if (documentOrId instanceof Uri) {
document = await workspace.openTextDocument(documentOrId);
} else if (documentOrUri instanceof Uri) {
document = await workspace.openTextDocument(documentOrUri);
} else {
document = documentOrId;
document = documentOrUri;
}
const doc = this.addCore(document);
return doc;
}
private _get(documentOrId: string | TextDocument | Uri) {
if (GitUri.is(documentOrId)) {
documentOrId = GitUri.toKey(documentOrId.documentUri());
} else if (typeof documentOrId === 'string' || documentOrId instanceof Uri) {
documentOrId = GitUri.toKey(documentOrId);
}
const doc = this._documentMap.get(documentOrId);
return doc;
}
private async addCore(document: TextDocument): Promise<TrackedDocument<T>> {
const key = GitUri.toKey(document.uri);
@ -348,6 +288,59 @@ export class DocumentTracker implements Disposable {
return doc;
}
async clear() {
for (const d of this._documentMap.values()) {
(await d).dispose();
}
this._documentMap.clear();
}
get(document: TextDocument): Promise<TrackedDocument<T>> | undefined;
get(uri: Uri): Promise<TrackedDocument<T>> | undefined;
get(documentOrUri: TextDocument | Uri): Promise<TrackedDocument<T>> | undefined;
get(documentOrUri: TextDocument | Uri): Promise<TrackedDocument<T>> | undefined {
let key;
if (GitUri.is(documentOrUri)) {
key = GitUri.toKey(documentOrUri.documentUri());
} else if (documentOrUri instanceof Uri) {
key = GitUri.toKey(documentOrUri);
} else {
key = documentOrUri;
}
const doc = this._documentMap.get(key);
return doc;
}
getOrAdd(document: TextDocument): Promise<TrackedDocument<T>>;
getOrAdd(uri: Uri): Promise<TrackedDocument<T>>;
async getOrAdd(documentOrUri: TextDocument | Uri): Promise<TrackedDocument<T>> {
const doc = this.get(documentOrUri) ?? this.add(documentOrUri);
return doc;
}
has(document: TextDocument): boolean;
has(uri: Uri): boolean;
has(documentOrUri: TextDocument | Uri): boolean {
if (documentOrUri instanceof Uri) {
return this._documentMap.has(GitUri.toKey(documentOrUri));
}
return this._documentMap.has(documentOrUri);
}
private async remove(document: TextDocument, tracked?: TrackedDocument<T>): Promise<void> {
let promise;
if (tracked != null) {
promise = this._documentMap.get(document);
}
this._documentMap.delete(document);
this._documentMap.delete(GitUri.toKey(document.uri));
(tracked ?? (await promise))?.dispose();
}
private _dirtyIdleTriggeredDebounced: Deferrable<(e: DocumentDirtyIdleTriggerEvent<T>) => void> | undefined;
private _dirtyStateChangedDebounced: Deferrable<(e: DocumentDirtyStateChangeEvent<T>) => void> | undefined;
private fireDocumentDirtyStateChanged(e: DocumentDirtyStateChangeEvent<T>) {

+ 80
- 6
src/trackers/gitDocumentTracker.ts View File

@ -1,3 +1,4 @@
import { TextDocument, Uri } from 'vscode';
import { GitBlame, GitDiff, GitLog } from '../git/models';
import { DocumentTracker } from './documentTracker';
@ -13,17 +14,90 @@ export type CachedDiff = CachedItem;
export type CachedLog = CachedItem<GitLog>;
export class GitDocumentState {
private cache = new Map<string, CachedBlame | CachedDiff | CachedLog>();
private readonly blameCache = new Map<string, CachedBlame>();
private readonly diffCache = new Map<string, CachedDiff>();
private readonly logCache = new Map<string, CachedLog>();
constructor(public readonly key: string) {}
get<T extends CachedBlame | CachedDiff | CachedLog>(key: string): T | undefined {
return this.cache.get(key) as T;
clearBlame(key?: string): void {
if (key == null) {
this.blameCache.clear();
return;
}
this.blameCache.delete(key);
}
set<T extends CachedBlame | CachedDiff | CachedLog>(key: string, value: T) {
this.cache.set(key, value);
clearDiff(key?: string): void {
if (key == null) {
this.diffCache.clear();
return;
}
this.diffCache.delete(key);
}
clearLog(key?: string): void {
if (key == null) {
this.logCache.clear();
return;
}
this.logCache.delete(key);
}
getBlame(key: string): CachedBlame | undefined {
return this.blameCache.get(key);
}
getDiff(key: string): CachedDiff | undefined {
return this.diffCache.get(key);
}
getLog(key: string): CachedLog | undefined {
return this.logCache.get(key);
}
setBlame(key: string, value: CachedBlame | undefined) {
if (value == null) {
this.blameCache.delete(key);
return;
}
this.blameCache.set(key, value);
}
setDiff(key: string, value: CachedDiff | undefined) {
if (value == null) {
this.diffCache.delete(key);
return;
}
this.diffCache.set(key, value);
}
setLog(key: string, value: CachedLog | undefined) {
if (value == null) {
this.logCache.delete(key);
return;
}
this.logCache.set(key, value);
}
}
export class GitDocumentTracker extends DocumentTracker<GitDocumentState> {}
export class GitDocumentTracker extends DocumentTracker<GitDocumentState> {
resetCache(document: TextDocument, affects: 'blame' | 'diff' | 'log'): Promise<void>;
resetCache(uri: Uri, affects: 'blame' | 'diff' | 'log'): Promise<void>;
async resetCache(documentOrUri: TextDocument | Uri, affects: 'blame' | 'diff' | 'log'): Promise<void> {
const doc = this.get(documentOrUri);
if (doc == null) return;
switch (affects) {
case 'blame':
(await doc).state?.clearBlame();
break;
case 'diff':
(await doc).state?.clearDiff();
break;
case 'log':
(await doc).state?.clearLog();
break;
}
}
}

+ 1
- 1
src/views/nodes/fileHistoryNode.ts View File

@ -1,6 +1,6 @@
import { Disposable, TreeItem, TreeItemCollapsibleState, window } from 'vscode';
import { configuration } from '../../configuration';
import { GitUri } from '../../git/gitUri';
import type { GitUri } from '../../git/gitUri';
import {
GitBranch,
GitLog,

+ 4
- 0
src/views/nodes/fileHistoryTrackerNode.ts View File

@ -134,6 +134,10 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
if (!this.canSubscribe) return false;
if (reset) {
if (this._uri != null && this._uri !== GitUri.unknown) {
await this.view.container.tracker.resetCache(this._uri, 'log');
}
this.reset();
}

+ 1
- 1
src/views/nodes/lineHistoryNode.ts View File

@ -1,5 +1,5 @@
import { Disposable, Selection, TreeItem, TreeItemCollapsibleState, window } from 'vscode';
import { GitUri } from '../../git/gitUri';
import type { GitUri } from '../../git/gitUri';
import {
GitBranch,
GitCommitType,

+ 4
- 0
src/views/nodes/lineHistoryTrackerNode.ts View File

@ -146,6 +146,10 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
if (!this.canSubscribe) return false;
if (reset) {
if (this._uri != null && this._uri !== GitUri.unknown) {
await this.view.container.tracker.resetCache(this._uri, 'log');
}
this.reset();
}

Loading…
Cancel
Save