git: dirty diff first steps
This commit is contained in:
parent
cf203e0914
commit
901810dc4a
29
extensions/git/src/dirtydiff.ts
Normal file
29
extensions/git/src/dirtydiff.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* 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 { Event, TextEditor, window } from 'vscode';
|
||||||
|
import { IDisposable, dispose, mapEvent } from './util';
|
||||||
|
|
||||||
|
type TextEditorsEvent = Event<TextEditor[]>;
|
||||||
|
|
||||||
|
export class DirtyDiffDecorator implements IDisposable {
|
||||||
|
|
||||||
|
private disposables: IDisposable[] = [];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
mapEvent(window.onDidChangeActiveTextEditor, () => window.visibleTextEditors)
|
||||||
|
(this.onDidVisibleEditorsChange, this, this.disposables);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onDidVisibleEditorsChange(textEditors: TextEditor[]) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose(): void {
|
||||||
|
this.disposables = dispose(this.disposables);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,15 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import * as vscode from 'vscode';
|
import { ExtensionContext } from 'vscode';
|
||||||
|
import { DirtyDiffDecorator } from './dirtydiff';
|
||||||
|
|
||||||
export function activate(context: vscode.ExtensionContext) { }
|
export function activate(context: ExtensionContext) {
|
||||||
export function deactivate() { }
|
context.subscriptions.push(
|
||||||
|
new DirtyDiffDecorator()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deactivate() {
|
||||||
|
|
||||||
|
}
|
25
extensions/git/src/util.ts
Normal file
25
extensions/git/src/util.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* 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 { Event } from 'vscode';
|
||||||
|
|
||||||
|
export interface IDisposable {
|
||||||
|
dispose(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dispose<T extends IDisposable>(disposables: T[]): T[] {
|
||||||
|
disposables.forEach(d => d.dispose());
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mapEvent<I, O>(event: Event<I>, map: (i: I) => O): Event<O> {
|
||||||
|
return (listener, thisArgs = null, disposables?) => event(i => listener.call(thisArgs, map(i)), null, disposables);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function filterEvent<T>(event: Event<T>, filter: (e: T) => boolean): Event<T> {
|
||||||
|
return (listener, thisArgs = null, disposables?) => event(e => filter(e) && listener.call(thisArgs, e), null, disposables);
|
||||||
|
}
|
|
@ -1,16 +1,11 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"noLib": true,
|
||||||
|
"target": "es5",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "es6",
|
"outDir": "./out"
|
||||||
"outDir": "out",
|
|
||||||
"lib": [
|
|
||||||
"es6"
|
|
||||||
],
|
|
||||||
"sourceMap": true,
|
|
||||||
"rootDir": "."
|
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules"
|
||||||
".vscode-test"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Reference in a new issue