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": {
|
"discord.detailsEditing": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "Editing {filename}",
|
"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": {
|
"discord.detailsDebugging": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "Debugging {filename}",
|
"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": {
|
"discord.detailsIdle": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -103,12 +103,12 @@
|
||||||
"discord.lowerDetailsEditing": {
|
"discord.lowerDetailsEditing": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "Workspace: {workspace}",
|
"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": {
|
"discord.lowerDetailsDebugging": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "Debugging: {workspace}",
|
"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": {
|
"discord.lowerDetailsIdle": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
@ -92,16 +92,14 @@ export async function activate(context: ExtensionContext) {
|
||||||
disableJoinRequests,
|
disableJoinRequests,
|
||||||
);
|
);
|
||||||
|
|
||||||
const gitExtension = extensions.getExtension<GitExtension>('vscode.git');
|
setTimeout(() => {
|
||||||
if (gitExtension) {
|
const gitExtension = extensions.getExtension<GitExtension>('vscode.git');
|
||||||
if (!gitExtension.exports.enabled) {
|
if (gitExtension) {
|
||||||
gitExtension.exports.onDidChangeEnablement(e => {
|
if (gitExtension.isActive) {
|
||||||
if (e) {
|
rpc.git = gitExtension.exports.getAPI(1);
|
||||||
rpc.git = gitExtension.exports.getAPI(1);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}, 5000);
|
||||||
|
|
||||||
if (!isWorkspaceExcluded && config.get<boolean>('enabled')) {
|
if (!isWorkspaceExcluded && config.get<boolean>('enabled')) {
|
||||||
statusBarIcon.show();
|
statusBarIcon.show();
|
||||||
|
|
|
@ -245,6 +245,7 @@ export default class Activity implements Disposable {
|
||||||
let filename = null;
|
let filename = null;
|
||||||
let dirname = null;
|
let dirname = null;
|
||||||
let checkState = false;
|
let checkState = false;
|
||||||
|
let workspaceName = null;
|
||||||
let workspaceFolder = null;
|
let workspaceFolder = null;
|
||||||
let fullDirname = null;
|
let fullDirname = null;
|
||||||
if (window.activeTextEditor) {
|
if (window.activeTextEditor) {
|
||||||
|
@ -255,7 +256,7 @@ export default class Activity implements Disposable {
|
||||||
dirname = split[split.length - 1];
|
dirname = split[split.length - 1];
|
||||||
|
|
||||||
checkState = Boolean(workspace.getWorkspaceFolder(window.activeTextEditor.document.uri));
|
checkState = Boolean(workspace.getWorkspaceFolder(window.activeTextEditor.document.uri));
|
||||||
|
workspaceName = workspace.name;
|
||||||
workspaceFolder = checkState ? workspace.getWorkspaceFolder(window.activeTextEditor.document.uri) : null;
|
workspaceFolder = checkState ? workspace.getWorkspaceFolder(window.activeTextEditor.document.uri) : null;
|
||||||
|
|
||||||
if (workspaceFolder) {
|
if (workspaceFolder) {
|
||||||
|
@ -281,6 +282,14 @@ export default class Activity implements Disposable {
|
||||||
.replace('{fulldirname}', fullDirname!)
|
.replace('{fulldirname}', fullDirname!)
|
||||||
.replace(
|
.replace(
|
||||||
'{workspace}',
|
'{workspace}',
|
||||||
|
workspaceName
|
||||||
|
? workspaceName
|
||||||
|
: checkState && workspaceFolder
|
||||||
|
? workspaceFolder.name
|
||||||
|
: this.client.config.get<string>('lowerDetailsNotFound')!.replace('{null}', empty),
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
'{workspaceFolder}',
|
||||||
checkState && workspaceFolder
|
checkState && workspaceFolder
|
||||||
? workspaceFolder.name
|
? workspaceFolder.name
|
||||||
: this.client.config.get<string>('lowerDetailsNotFound')!.replace('{null}', empty),
|
: this.client.config.get<string>('lowerDetailsNotFound')!.replace('{null}', empty),
|
||||||
|
|
Loading…
Reference in a new issue