fix: git api
This commit is contained in:
parent
705dd7b626
commit
9f6385e8fd
3 changed files with 21 additions and 14 deletions
|
@ -88,12 +88,12 @@
|
|||
"discord.detailsEditing": {
|
||||
"type": "string",
|
||||
"default": "Editing {filename}",
|
||||
"description": "Custom string for the details section of the rich presence\n\t- '{null}' will be replaced with an empty space.\n\t- '{filename}' will be replaced with the current file name.\n\t- '{dirname}' will get replaced with the folder name that has the current file.\n\t- '{fulldirname}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{currentcolumn}' will get replaced with the current column of the current line.\n\t- '{currentline}' will get replaced with the current line number.\n\t- '{totallines}' will get replaced with the total line number.\n\t- '{filesize}' will get replaced with the current file's size.\n\t- '{gitreponame}' will be replaced with the active Git repository name (from the git URL)\n\t- '{gitbranch}' will be replaced with the current active branch name."
|
||||
"description": "Custom string for the details section of the rich presence\n\t- '{null}' will be replaced with an empty space.\n\t- '{filename}' will be replaced with the current file name.\n\t- '{dirname}' will get replaced with the folder name that has the current file.\n\t- '{fulldirname}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspaceFolder}' will be replaced witht he currently access workspace folder, if any.\n\t- '{currentcolumn}' will get replaced with the current column of the current line.\n\t- '{currentline}' will get replaced with the current line number.\n\t- '{totallines}' will get replaced with the total line number.\n\t- '{filesize}' will get replaced with the current file's size.\n\t- '{gitreponame}' will be replaced with the active Git repository name (from the git URL)\n\t- '{gitbranch}' will be replaced with the current active branch name."
|
||||
},
|
||||
"discord.detailsDebugging": {
|
||||
"type": "string",
|
||||
"default": "Debugging {filename}",
|
||||
"description": "Custom string for the details section of the rich presence when debugging\n\t- '{null}' will be replaced with an empty space.\n\t- '{filename}' will be replaced with the current file name.\n\t- '{dirname}' will get replaced with the folder name that has the current file.\n\t- '{fulldirname}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{currentcolumn}' will get replaced with the current column of the current line.\n\t- '{currentline}' will get replaced with the current line number.\n\t- '{totallines}' will get replaced with the total line number.\n\t- '{filesize}' will get replaced with the current file's size.\n\t- '{gitreponame}' will be replaced with the active Git repository name (from the git URL)\n\t- '{gitbranch}' will be replaced with the current active branch name."
|
||||
"description": "Custom string for the details section of the rich presence when debugging\n\t- '{null}' will be replaced with an empty space.\n\t- '{filename}' will be replaced with the current file name.\n\t- '{dirname}' will get replaced with the folder name that has the current file.\n\t- '{fulldirname}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspaceFolder}' will be replaced witht he currently access workspace folder, if any.\n\t- '{currentcolumn}' will get replaced with the current column of the current line.\n\t- '{currentline}' will get replaced with the current line number.\n\t- '{totallines}' will get replaced with the total line number.\n\t- '{filesize}' will get replaced with the current file's size.\n\t- '{gitreponame}' will be replaced with the active Git repository name (from the git URL)\n\t- '{gitbranch}' will be replaced with the current active branch name."
|
||||
},
|
||||
"discord.detailsIdle": {
|
||||
"type": "string",
|
||||
|
@ -103,12 +103,12 @@
|
|||
"discord.lowerDetailsEditing": {
|
||||
"type": "string",
|
||||
"default": "Workspace: {workspace}",
|
||||
"description": "Custom string for the state section of the rich presence\n\t- '{null}' will be replaced with an empty space.\n\t- '{filename}' will be replaced with the current file name.\n\t- '{dirname}' will get replaced with the folder name that has the current file.\n\t- '{fulldirname}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{currentcolumn}' will get replaced with the current column of the current line.\n\t- '{currentline}' will get replaced with the current line number.\n\t- '{totallines}' will get replaced with the total line number.\n\t- '{filesize}' will get replaced with the current file's size.\n\t- '{gitreponame}' will be replaced with the active Git repository name (from the git URL)\n\t- '{gitbranch}' will be replaced with the current active branch name."
|
||||
"description": "Custom string for the state section of the rich presence\n\t- '{null}' will be replaced with an empty space.\n\t- '{filename}' will be replaced with the current file name.\n\t- '{dirname}' will get replaced with the folder name that has the current file.\n\t- '{fulldirname}' will get replaced with the full directory name without the current file name.\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspaceFolder}' will be replaced witht he currently access workspace folder, if any.\n\t- '{currentcolumn}' will get replaced with the current column of the current line.\n\t- '{currentline}' will get replaced with the current line number.\n\t- '{totallines}' will get replaced with the total line number.\n\t- '{filesize}' will get replaced with the current file's size.\n\t- '{gitreponame}' will be replaced with the active Git repository name (from the git URL)\n\t- '{gitbranch}' will be replaced with the current active branch name."
|
||||
},
|
||||
"discord.lowerDetailsDebugging": {
|
||||
"type": "string",
|
||||
"default": "Debugging: {workspace}",
|
||||
"description": "Custom string for the state section of the rich presence when debugging\n\t- '{null}' will be replaced with an empty space.\n\t- '{filename}' will be replaced with the current file name.\n\t- '{dirname}' will get replaced with the folder name that has the current file.\n\t- '{fulldirname}' will get replaced with the full directory name without the current file name..\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{currentcolumn}' will get replaced with the current column of the current line.\n\t- '{currentline}' will get replaced with the current line number.\n\t- '{totallines}' will get replaced with the total line number.\n\t- '{filesize}' will get replaced with the current file's size.\n\t- '{gitreponame}' will be replaced with the active Git repository name (from the git URL)\n\t- '{gitbranch}' will be replaced with the current active branch name."
|
||||
"description": "Custom string for the state section of the rich presence when debugging\n\t- '{null}' will be replaced with an empty space.\n\t- '{filename}' will be replaced with the current file name.\n\t- '{dirname}' will get replaced with the folder name that has the current file.\n\t- '{fulldirname}' will get replaced with the full directory name without the current file name..\n\t- '{workspace}' will be replaced with the current workspace name, if any.\n\t- '{workspaceFolder}' will be replaced witht he currently access workspace folder, if any.\n\t- '{currentcolumn}' will get replaced with the current column of the current line.\n\t- '{currentline}' will get replaced with the current line number.\n\t- '{totallines}' will get replaced with the total line number.\n\t- '{filesize}' will get replaced with the current file's size.\n\t- '{gitreponame}' will be replaced with the active Git repository name (from the git URL)\n\t- '{gitbranch}' will be replaced with the current active branch name."
|
||||
},
|
||||
"discord.lowerDetailsIdle": {
|
||||
"type": "string",
|
||||
|
|
|
@ -92,16 +92,14 @@ export async function activate(context: ExtensionContext) {
|
|||
disableJoinRequests,
|
||||
);
|
||||
|
||||
const gitExtension = extensions.getExtension<GitExtension>('vscode.git');
|
||||
if (gitExtension) {
|
||||
if (!gitExtension.exports.enabled) {
|
||||
gitExtension.exports.onDidChangeEnablement(e => {
|
||||
if (e) {
|
||||
rpc.git = gitExtension.exports.getAPI(1);
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
const gitExtension = extensions.getExtension<GitExtension>('vscode.git');
|
||||
if (gitExtension) {
|
||||
if (gitExtension.isActive) {
|
||||
rpc.git = gitExtension.exports.getAPI(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
if (!isWorkspaceExcluded && config.get<boolean>('enabled')) {
|
||||
statusBarIcon.show();
|
||||
|
|
|
@ -245,6 +245,7 @@ export default class Activity implements Disposable {
|
|||
let filename = null;
|
||||
let dirname = null;
|
||||
let checkState = false;
|
||||
let workspaceName = null;
|
||||
let workspaceFolder = null;
|
||||
let fullDirname = null;
|
||||
if (window.activeTextEditor) {
|
||||
|
@ -255,7 +256,7 @@ export default class Activity implements Disposable {
|
|||
dirname = split[split.length - 1];
|
||||
|
||||
checkState = Boolean(workspace.getWorkspaceFolder(window.activeTextEditor.document.uri));
|
||||
|
||||
workspaceName = workspace.name;
|
||||
workspaceFolder = checkState ? workspace.getWorkspaceFolder(window.activeTextEditor.document.uri) : null;
|
||||
|
||||
if (workspaceFolder) {
|
||||
|
@ -281,6 +282,14 @@ export default class Activity implements Disposable {
|
|||
.replace('{fulldirname}', fullDirname!)
|
||||
.replace(
|
||||
'{workspace}',
|
||||
workspaceName
|
||||
? workspaceName
|
||||
: checkState && workspaceFolder
|
||||
? workspaceFolder.name
|
||||
: this.client.config.get<string>('lowerDetailsNotFound')!.replace('{null}', empty),
|
||||
)
|
||||
.replace(
|
||||
'{workspaceFolder}',
|
||||
checkState && workspaceFolder
|
||||
? workspaceFolder.name
|
||||
: this.client.config.get<string>('lowerDetailsNotFound')!.replace('{null}', empty),
|
||||
|
|
Loading…
Reference in a new issue