Skip to content

Commit 30e834b

Browse files
committed
Merge branch 'master' into status_file_explorer
# Conflicts: # src/extension.ts # src/model.ts
2 parents 9249408 + c275349 commit 30e834b

File tree

7 files changed

+46
-21
lines changed

7 files changed

+46
-21
lines changed
Lines changed: 1 addition & 1 deletion
Loading

icons/dark/open-change-head.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 1 deletion
Loading

icons/light/open-change-head.svg

Lines changed: 1 addition & 0 deletions
Loading

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@
8888
"title": "Open Changes with BASE",
8989
"category": "SVN",
9090
"icon": {
91-
"light": "icons/light/open-change.svg",
92-
"dark": "icons/dark/open-change.svg"
91+
"light": "icons/light/open-change-base.svg",
92+
"dark": "icons/dark/open-change-base.svg"
9393
}
9494
},
9595
{
9696
"command": "svn.openChangeHead",
9797
"title": "Open Changes with HEAD",
9898
"category": "SVN",
9999
"icon": {
100-
"light": "icons/light/open-change.svg",
101-
"dark": "icons/dark/open-change.svg"
100+
"light": "icons/light/open-change-head.svg",
101+
"dark": "icons/dark/open-change-head.svg"
102102
}
103103
},
104104
{
@@ -164,19 +164,19 @@
164164
"commandPalette": [
165165
{
166166
"command": "svn.openFile",
167-
"when": "config.svn.enabled"
167+
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
168168
},
169169
{
170170
"command": "svn.openHEADFile",
171-
"when": "config.svn.enabled"
171+
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
172172
},
173173
{
174174
"command": "svn.openChangeBase",
175-
"when": "config.svn.enabled"
175+
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
176176
},
177177
{
178178
"command": "svn.openChangeHead",
179-
"when": "config.svn.enabled"
179+
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
180180
}
181181
],
182182
"scm/title": [
@@ -292,19 +292,19 @@
292292
"command": "svn.openFile",
293293
"group": "navigation",
294294
"when":
295-
"config.svn.enabled && isInDiffEditor && resourceScheme != extension && resourceScheme != merge-conflict.conflict-diff"
295+
"config.svn.enabled && svnOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme != extension && resourceScheme != merge-conflict.conflict-diff"
296296
},
297297
{
298298
"command": "svn.openChangeBase",
299299
"group": "navigation",
300300
"when":
301-
"config.svn.enabled && !isInDiffEditor && resourceScheme == file"
301+
"config.svn.enabled && svnOpenRepositoryCount != 0 && !isInDiffEditor && resourceScheme == file"
302302
},
303303
{
304304
"command": "svn.openChangeHead",
305305
"group": "navigation",
306306
"when":
307-
"config.svn.enabled && !isInDiffEditor && resourceScheme == file"
307+
"config.svn.enabled && svnOpenRepositoryCount != 0 && !isInDiffEditor && resourceScheme == file"
308308
}
309309
]
310310
},

src/extension.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { ExtensionContext, Disposable, workspace, window } from "vscode";
1+
import {
2+
ExtensionContext,
3+
Disposable,
4+
workspace,
5+
window,
6+
commands
7+
} from "vscode";
28
import { Svn } from "./svn";
39
import { SvnFinder } from "./svnFinder";
410
import { SvnContentProvider } from "./svnContentProvider";
@@ -26,7 +32,7 @@ async function init(context: ExtensionContext, disposables: Disposable[]) {
2632
const svn = new Svn({ svnPath: info.path, version: info.version });
2733
const model = new Model(svn);
2834
const contentProvider = new SvnContentProvider(model);
29-
const commands = new SvnCommands(model);
35+
const svnCommands = new SvnCommands(model);
3036
disposables.push(model, contentProvider);
3137

3238
// First, check the vscode has support to DecorationProvider
@@ -36,6 +42,15 @@ async function init(context: ExtensionContext, disposables: Disposable[]) {
3642
disposables.push(decoration);
3743
});
3844
}
45+
const onRepository = () =>
46+
commands.executeCommand(
47+
"setContext",
48+
"svnOpenRepositoryCount",
49+
`${model.repositories.length}`
50+
);
51+
model.onDidOpenRepository(onRepository, null, disposables);
52+
model.onDidCloseRepository(onRepository, null, disposables);
53+
onRepository();
3954

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

src/model.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface OriginalResourceChangeEvent {
2525
uri: Uri;
2626
}
2727

28-
interface OpenRepository {
28+
interface OpenRepository extends Disposable {
2929
repository: Repository;
3030
}
3131

@@ -34,9 +34,9 @@ export class Model {
3434
readonly onDidOpenRepository: Event<Repository> = this._onDidOpenRepository
3535
.event;
3636

37-
// private _onDidCloseRepository = new EventEmitter<Repository>();
38-
// readonly onDidCloseRepository: Event<Repository> = this._onDidCloseRepository
39-
// .event;
37+
private _onDidCloseRepository = new EventEmitter<Repository>();
38+
readonly onDidCloseRepository: Event<Repository> = this._onDidCloseRepository
39+
.event;
4040

4141
private _onDidChangeRepository = new EventEmitter<ModelChangeEvent>();
4242
readonly onDidChangeRepository: Event<ModelChangeEvent> = this
@@ -288,10 +288,18 @@ export class Model {
288288
this._onDidChangeRepository.fire({ repository, uri })
289289
);
290290

291-
this.disposables.push(changeListener);
291+
const dispose = () => {
292+
changeListener.dispose();
293+
repository.dispose();
292294

293-
this.openRepositories.push({ repository });
295+
this.openRepositories = this.openRepositories.filter(
296+
e => e !== openRepository
297+
);
298+
this._onDidCloseRepository.fire(repository);
299+
};
294300

301+
const openRepository = { repository, dispose };
302+
this.openRepositories.push(openRepository);
295303
this._onDidOpenRepository.fire(repository);
296304
}
297305

0 commit comments

Comments
 (0)