提交 10e257e7 编写于 作者: J Joao Moreno

git: basic status bar

上级 af4aedcf
......@@ -11,6 +11,7 @@ import { findGit, Git } from './git';
import { Model } from './model';
import { GitSCMProvider } from './scmProvider';
import { registerCommands } from './commands';
import { StatusBar } from './statusbar';
import { filterEvent, anyEvent, throttle } from './util';
import * as nls from 'vscode-nls';
import { decorate, debounce } from 'core-decorators';
......@@ -111,6 +112,8 @@ async function init(disposables: Disposable[]): Promise<void> {
const watcher = new Watcher(model, onWorkspaceChange);
const textDocumentContentProvider = new TextDocumentContentProvider(git, rootPath, onGitChange);
const statusBar = new StatusBar(model);
disposables.push(
registerCommands(model),
scm.registerSCMProvider('git', provider),
......@@ -118,7 +121,8 @@ async function init(disposables: Disposable[]): Promise<void> {
textDocumentContentProvider,
outputChannel,
fsWatcher,
watcher
watcher,
statusBar
);
}
......
......@@ -8,7 +8,7 @@
import { Uri, EventEmitter, Event, SCMResource, SCMResourceDecorations, SCMResourceGroup } from 'vscode';
import { Repository, IRef, IRemote } from './git';
import { throttle } from './util';
import { decorate, debounce } from 'core-decorators';
import { decorate } from 'core-decorators';
import * as path from 'path';
const iconsRootPath = path.join(path.dirname(__dirname), 'resources', 'icons');
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { window, Disposable, StatusBarItem, StatusBarAlignment } from 'vscode';
import { IRef, RefType } from './git';
import { Model } from './model';
export class StatusBar {
private raw: StatusBarItem;
private disposables: Disposable[] = [];
constructor(private model: Model) {
this.raw = window.createStatusBarItem(StatusBarAlignment.Left);
this.raw.show();
this.disposables.push(this.raw);
model.onDidChange(this.update, this, this.disposables);
this.update();
}
private update(): void {
const HEAD = this.model.HEAD;
if (!HEAD) {
this.raw.color = 'rgb(100, 100, 100)';
this.raw.text = 'unknown';
return;
}
const tag = this.model.refs.filter(iref => iref.type === RefType.Tag && iref.commit === HEAD.commit)[0];
const tagName = tag && tag.name;
const head = HEAD.name || tagName || (HEAD.commit || '').substr(0, 8);
this.raw.color = 'rgb(255, 255, 255)';
this.raw.text = head +
(this.model.workingTreeGroup.resources.length > 0 ? '*' : '') +
(this.model.indexGroup.resources.length > 0 ? '+' : '') +
(this.model.mergeGroup.resources.length > 0 ? '!' : '');
}
dispose(): void {
this.disposables.forEach(d => d.dispose());
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册