Browse Source

Changes to use decoration for default indicator

main
Eric Amodio 4 years ago
parent
commit
94bea8057d
2 changed files with 25 additions and 8 deletions
  1. +4
    -6
      src/views/nodes/remoteNode.ts
  2. +21
    -2
      src/views/viewDecorationProvider.ts

+ 4
- 6
src/views/nodes/remoteNode.ts View File

@ -1,5 +1,5 @@
'use strict';
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import { BranchNode } from './branchNode';
import { BranchOrTagFolderNode } from './branchOrTagFolderNode';
import { MessageNode } from './common';
@ -106,10 +106,7 @@ export class RemoteNode extends ViewNode {
arrows = GlyphChars.Dash;
}
const item = new TreeItem(
`${this.remote.default ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${this.remote.name}`,
TreeItemCollapsibleState.Collapsed,
);
const item = new TreeItem(this.remote.name, TreeItemCollapsibleState.Collapsed);
if (this.remote.provider != null) {
const { provider } = this.remote;
@ -123,7 +120,7 @@ export class RemoteNode extends ViewNode {
if (provider.hasApi()) {
const connected = provider.maybeConnected ?? (await provider.isConnected());
item.contextValue += `${ContextValues.Remote}${connected ? '+connected' : '+disconnected'}`;
item.contextValue = `${ContextValues.Remote}${connected ? '+connected' : '+disconnected'}`;
item.tooltip = `${this.remote.name} (${provider.name} ${GlyphChars.Dash} ${
connected ? 'connected' : 'not connected'
})\n${provider.displayPath}\n`;
@ -144,6 +141,7 @@ export class RemoteNode extends ViewNode {
if (this.remote.default) {
item.contextValue += '+default';
item.resourceUri = Uri.parse('gitlens-view://remote/default');
}
item.id = this.id;

+ 21
- 2
src/views/viewDecorationProvider.ts View File

@ -25,9 +25,17 @@ export class ViewFileDecorationProvider implements FileDecorationProvider, Dispo
// Register the current branch decorator separately (since we can only have 2 char's per decoration)
window.registerFileDecorationProvider({
provideFileDecoration: (uri, token) => {
if (uri.scheme !== 'gitlens-view' || uri.authority !== 'branch') return undefined;
if (uri.scheme !== 'gitlens-view') return undefined;
return this.provideBranchCurrentDecoration(uri, token);
if (uri.authority === 'branch') {
return this.provideBranchCurrentDecoration(uri, token);
}
if (uri.authority === 'remote') {
return this.provideRemoteDefaultDecoration(uri, token);
}
return undefined;
},
}),
window.registerFileDecorationProvider(this),
@ -171,4 +179,15 @@ export class ViewFileDecorationProvider implements FileDecorationProvider, Dispo
tooltip: 'Current Branch',
};
}
provideRemoteDefaultDecoration(uri: Uri, _token: CancellationToken): FileDecoration | undefined {
const [, isDefault] = uri.path.split('/');
if (!isDefault) return undefined;
return {
badge: GlyphChars.Check,
tooltip: 'Default Remote',
};
}
}

||||||
x
 
000:0
Loading…
Cancel
Save