Skip to content

Commit f33ce51

Browse files
committed
Added check for register diff command
1 parent 97e8957 commit f33ce51

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
},
229229
{
230230
"command": "svn.revertSelectedRanges",
231-
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
231+
"when": "config.svn.enabled && svnOpenRepositoryCount != 0 && svnHasSupportToRegisterDiffCommand == 1"
232232
}
233233
],
234234
"scm/title": [
@@ -373,7 +373,7 @@
373373
"command": "svn.revertSelectedRanges",
374374
"group": "2_svn@3",
375375
"when":
376-
"config.svn.enabled && svnOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme != merge-conflict.conflict-diff"
376+
"config.svn.enabled && svnOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme != merge-conflict.conflict-diff && && svnHasSupportToRegisterDiffCommand == 1"
377377
}
378378
]
379379
},

src/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import * as path from "path";
2828
import { start } from "repl";
2929
import { getConflictPickOptions } from "./conflictItems";
3030
import { applyLineChanges } from "./lineChanges";
31-
import { IDisposable } from "./util";
31+
import { IDisposable, hasSupportToRegisterDiffCommand } from "./util";
3232
import {
3333
getChangelistPickOptions,
3434
inputSwitchChangelist,
@@ -124,7 +124,7 @@ export class SvnCommands implements IDisposable {
124124
constructor(private model: Model) {
125125
this.disposables = Commands.map(({ commandId, method, options }) => {
126126
const command = this.createCommand(method, options);
127-
if (options.diff) {
127+
if (options.diff && hasSupportToRegisterDiffCommand()) {
128128
return commands.registerDiffInformationCommand(commandId, command);
129129
} else {
130130
return commands.registerCommand(commandId, command);

src/extension.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import { SvnFinder } from "./svnFinder";
1010
import { SvnContentProvider } from "./svnContentProvider";
1111
import { SvnCommands } from "./commands";
1212
import { Model } from "./model";
13-
import { toDisposable, hasSupportToDecorationProvider } from "./util";
13+
import {
14+
toDisposable,
15+
hasSupportToDecorationProvider,
16+
hasSupportToRegisterDiffCommand
17+
} from "./util";
1418

1519
async function init(context: ExtensionContext, disposables: Disposable[]) {
1620
const outputChannel = window.createOutputChannel("Svn");
@@ -52,6 +56,12 @@ async function init(context: ExtensionContext, disposables: Disposable[]) {
5256
model.onDidCloseRepository(onRepository, null, disposables);
5357
onRepository();
5458

59+
commands.executeCommand(
60+
"setContext",
61+
"svnHasSupportToRegisterDiffCommand",
62+
hasSupportToRegisterDiffCommand() ? "1" : "0"
63+
);
64+
5565
outputChannel.appendLine("Using svn " + info.version + " from " + info.path);
5666

5767
const onOutput = (str: string) => outputChannel.append(str);

src/util.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Event, window } from "vscode";
1+
import { Event, window, commands } from "vscode";
22
import { sep } from "path";
33

44
export interface IDisposable {
@@ -36,9 +36,7 @@ export function dispose(disposables: any[]): any[] {
3636
return [];
3737
}
3838

39-
export function combinedDisposable(
40-
disposables: IDisposable[]
41-
): IDisposable {
39+
export function combinedDisposable(disposables: IDisposable[]): IDisposable {
4240
return toDisposable(() => dispose(disposables));
4341
}
4442

@@ -103,6 +101,19 @@ export function hasSupportToDecorationProvider() {
103101
return typeof window.registerDecorationProvider === "function";
104102
}
105103

104+
export function hasSupportToRegisterDiffCommand() {
105+
try {
106+
const disposable = commands.registerDiffInformationCommand(
107+
"svn.testDiff",
108+
() => {}
109+
);
110+
disposable.dispose();
111+
return true;
112+
} catch (error) {
113+
return false;
114+
}
115+
}
116+
106117
export function timeout(ms: number) {
107118
return new Promise(resolve => setTimeout(resolve, ms));
108119
}

0 commit comments

Comments
 (0)