-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from SAP/Done.isInTheia
isInTheia - mapping vscode commands to theia commands [Revert this ch…
- Loading branch information
Showing
4 changed files
with
62 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// TODO: remove this class when those vscode commands are implemented in theia. | ||
import * as vscode from "vscode"; | ||
|
||
export class Theia { | ||
private isInTheiaCached: boolean; | ||
private commandMappings: Map<string, string>; | ||
|
||
constructor() { | ||
this.isInTheiaCached = undefined; | ||
this.commandMappings = new Map(); | ||
this.initCommandMappings(); | ||
} | ||
|
||
private initCommandMappings(): void { | ||
this.commandMappings.set("vscode.openFolder", "workspace:openWorkspace"); | ||
this.commandMappings.set("workbench.action.closeActiveEditor", "core.close.tab"); | ||
} | ||
|
||
public getCommandMappings(): Map<string, string> { | ||
return this.commandMappings; | ||
} | ||
|
||
/** | ||
* isInTheia - just one way of finding out whether running in Theia (can/should be changed) | ||
*/ | ||
public async isInTheia(): Promise<boolean> { | ||
if (this.isInTheiaCached !== undefined) { | ||
return Promise.resolve(this.isInTheiaCached); | ||
} | ||
|
||
return vscode.commands.getCommands(true).then((commands) => { | ||
return this.isInTheiaCached = (commands.indexOf("change_theme") >= 0); | ||
}); | ||
} | ||
|
||
} |