Skip to content

Commit

Permalink
Merge pull request #152 from edgardmessias/fix_149
Browse files Browse the repository at this point in the history
Improved detection of support for decoration provider(Close #149)
  • Loading branch information
JohnstonCode authored Feb 9, 2018
2 parents c1390f9 + ac79954 commit de3f42e
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,36 @@ export function camelcase(name: string) {
.replace(/[\s\-]+/g, "");
}

let hasDecorationProvider = false;
export function hasSupportToDecorationProvider() {
return typeof window.registerDecorationProvider === "function";
return hasDecorationProvider;
}

try {
const fake = {
onDidChangeDecorations: (value: any): any => toDisposable(() => {}),
provideDecoration: (uri: any, token: any): any => {},
dispose: () => {}
};
const disposable = window.registerDecorationProvider(fake);
hasDecorationProvider = true;
disposable.dispose();
} catch (error) {}

let hasRegisterDiffCommand = false;
export function hasSupportToRegisterDiffCommand() {
try {
const disposable = commands.registerDiffInformationCommand(
"svn.testDiff",
() => {}
);
disposable.dispose();
return true;
} catch (error) {
return false;
}
return hasRegisterDiffCommand;
}

try {
const disposable = commands.registerDiffInformationCommand(
"svn.testDiff",
() => {}
);
hasRegisterDiffCommand = true;
disposable.dispose();
} catch (error) {}

export function timeout(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}

0 comments on commit de3f42e

Please sign in to comment.