mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
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';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { ExtensionContext } from 'vscode';
|
||||
import { DirtyDiffDecorator } from './dirtydiff';
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) { }
|
||||
export function deactivate() { }
|
||||
export function activate(context: ExtensionContext) {
|
||||
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": {
|
||||
"noLib": true,
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"outDir": "out",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"rootDir": "."
|
||||
"outDir": "./out"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode-test"
|
||||
"node_modules"
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue