Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/dark/open-change-head.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/light/open-change-head.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@
"title": "Open Changes with BASE",
"category": "SVN",
"icon": {
"light": "icons/light/open-change.svg",
"dark": "icons/dark/open-change.svg"
"light": "icons/light/open-change-base.svg",
"dark": "icons/dark/open-change-base.svg"
}
},
{
"command": "svn.openChangeHead",
"title": "Open Changes with HEAD",
"category": "SVN",
"icon": {
"light": "icons/light/open-change.svg",
"dark": "icons/dark/open-change.svg"
"light": "icons/light/open-change-head.svg",
"dark": "icons/dark/open-change-head.svg"
}
},
{
Expand Down Expand Up @@ -164,19 +164,19 @@
"commandPalette": [
{
"command": "svn.openFile",
"when": "config.svn.enabled"
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
},
{
"command": "svn.openHEADFile",
"when": "config.svn.enabled"
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
},
{
"command": "svn.openChangeBase",
"when": "config.svn.enabled"
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
},
{
"command": "svn.openChangeHead",
"when": "config.svn.enabled"
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
}
],
"scm/title": [
Expand Down Expand Up @@ -292,19 +292,19 @@
"command": "svn.openFile",
"group": "navigation",
"when":
"config.svn.enabled && isInDiffEditor && resourceScheme != extension && resourceScheme != merge-conflict.conflict-diff"
"config.svn.enabled && svnOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme != extension && resourceScheme != merge-conflict.conflict-diff"
},
{
"command": "svn.openChangeBase",
"group": "navigation",
"when":
"config.svn.enabled && !isInDiffEditor && resourceScheme == file"
"config.svn.enabled && svnOpenRepositoryCount != 0 && !isInDiffEditor && resourceScheme == file"
},
{
"command": "svn.openChangeHead",
"group": "navigation",
"when":
"config.svn.enabled && !isInDiffEditor && resourceScheme == file"
"config.svn.enabled && svnOpenRepositoryCount != 0 && !isInDiffEditor && resourceScheme == file"
}
]
},
Expand Down
20 changes: 18 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { ExtensionContext, Disposable, workspace, window } from "vscode";
import {
ExtensionContext,
Disposable,
workspace,
window,
commands
} from "vscode";
import { Svn } from "./svn";
import { SvnFinder } from "./svnFinder";
import { SvnContentProvider } from "./svnContentProvider";
Expand Down Expand Up @@ -26,9 +32,19 @@ async function init(context: ExtensionContext, disposables: Disposable[]) {
const svn = new Svn({ svnPath: info.path, version: info.version });
const model = new Model(svn);
const contentProvider = new SvnContentProvider(model);
const commands = new SvnCommands(model);
const svnCommands = new SvnCommands(model);
disposables.push(model, contentProvider);

const onRepository = () =>
commands.executeCommand(
"setContext",
"svnOpenRepositoryCount",
`${model.repositories.length}`
);
model.onDidOpenRepository(onRepository, null, disposables);
model.onDidCloseRepository(onRepository, null, disposables);
onRepository();

outputChannel.appendLine("Using svn " + info.version + " from " + info.path);

context.subscriptions.push(
Expand Down
24 changes: 21 additions & 3 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ export interface OriginalResourceChangeEvent {
uri: Uri;
}

interface OpenRepository {
interface OpenRepository extends Disposable {
repository: Repository;
}

export class Model {
private _onDidOpenRepository = new EventEmitter<Repository>();
readonly onDidOpenRepository: Event<Repository> = this._onDidOpenRepository
.event;

private _onDidCloseRepository = new EventEmitter<Repository>();
readonly onDidCloseRepository: Event<Repository> = this._onDidCloseRepository
.event;

private _onDidChangeRepository = new EventEmitter<ModelChangeEvent>();
readonly onDidChangeRepository: Event<ModelChangeEvent> = this
._onDidChangeRepository.event;
Expand Down Expand Up @@ -280,9 +288,19 @@ export class Model {
this._onDidChangeRepository.fire({ repository, uri })
);

this.disposables.push(changeListener);
const dispose = () => {
changeListener.dispose();
repository.dispose();

this.openRepositories = this.openRepositories.filter(
e => e !== openRepository
);
this._onDidCloseRepository.fire(repository);
};

this.openRepositories.push({ repository });
const openRepository = { repository, dispose };
this.openRepositories.push(openRepository);
this._onDidOpenRepository.fire(repository);
}

async pickRepository() {
Expand Down