Pārlūkot izejas kodu

Fixes errors on document outside of a repo

main
Eric Amodio pirms 2 gadiem
vecāks
revīzija
2a9a2e5181
3 mainītis faili ar 39 papildinājumiem un 19 dzēšanām
  1. +7
    -1
      src/git/gitProviderService.ts
  2. +14
    -6
      src/views/nodes/fileHistoryTrackerNode.ts
  3. +18
    -12
      src/views/nodes/lineHistoryTrackerNode.ts

+ 7
- 1
src/git/gitProviderService.ts Parādīt failu

@ -571,12 +571,18 @@ export class GitProviderService implements Disposable {
}
static getProviderId(repoPath: string | Uri): GitProviderId {
if (repoPath == null) {
// eslint-disable-next-line no-debugger
debugger;
throw new Error('Unsupported provider; no repository path');
}
if (typeof repoPath !== 'string' && repoPath.scheme === DocumentSchemes.VirtualFS) {
if (repoPath.authority.startsWith('github')) {
return GitProviderId.GitHub;
}
throw new Error(`Unsupported scheme: ${repoPath.scheme}`);
throw new Error(`Unsupported provider: ${repoPath.scheme}`);
}
return GitProviderId.Git;

+ 14
- 6
src/views/nodes/fileHistoryTrackerNode.ts Parādīt failu

@ -133,8 +133,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
if (!this.canSubscribe) return false;
if (reset) {
this.setUri();
this.resetChild();
this.reset();
}
const editor = window.activeTextEditor;
@ -147,8 +146,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
return true;
}
this.setUri();
this.resetChild();
this.reset();
if (cc != null) {
cc.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
@ -182,8 +180,13 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
gitUri = await GitUri.fromUri(uri);
}
this.setUri(gitUri);
this.resetChild();
// If we have no repoPath then don't attempt to use the Uri
if (gitUri.repoPath == null) {
this.reset();
} else {
this.setUri(gitUri);
this.resetChild();
}
if (cc != null) {
cc.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
@ -191,6 +194,11 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
return false;
}
private reset() {
this.setUri();
this.resetChild();
}
@log()
setEditorFollowing(enabled: boolean) {
if (enabled) {

+ 18
- 12
src/views/nodes/lineHistoryTrackerNode.ts Parādīt failu

@ -145,10 +145,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
if (!this.canSubscribe) return false;
if (reset) {
this.setUri();
this._editorContents = undefined;
this._selection = undefined;
this.resetChild();
this.reset();
}
const editor = window.activeTextEditor;
@ -161,10 +158,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
return true;
}
this.setUri();
this._editorContents = undefined;
this._selection = undefined;
this.resetChild();
this.reset();
if (cc != null) {
cc.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
@ -194,10 +188,15 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
return true;
}
this.setUri(gitUri);
this._editorContents = editor.document.isDirty ? editor.document.getText() : undefined;
this._selection = editor.selection;
this.resetChild();
// If we have no repoPath then don't attempt to use the Uri
if (gitUri.repoPath == null) {
this.reset();
} else {
this.setUri(gitUri);
this._editorContents = editor.document.isDirty ? editor.document.getText() : undefined;
this._selection = editor.selection;
this.resetChild();
}
if (cc != null) {
cc.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
@ -205,6 +204,13 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
return false;
}
private reset() {
this.setUri();
this._editorContents = undefined;
this._selection = undefined;
this.resetChild();
}
@log()
setEditorFollowing(enabled: boolean) {
this.canSubscribe = enabled;

Notiek ielāde…
Atcelt
Saglabāt