From 8fc1461fffa3131853938811e554544989620a34 Mon Sep 17 00:00:00 2001 From: Frangu Vlad Date: Tue, 13 Feb 2018 02:11:28 +0200 Subject: [PATCH] Allow people to set the state or details section to be empty (#47) --- package.json | 8 ++++---- src/extension.ts | 23 +++++++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 2cc2508..f2e9e2d 100644 --- a/package.json +++ b/package.json @@ -63,12 +63,12 @@ "discord.detailsEditing": { "type": "string", "default": "Editing {filename}", - "description": "Custom string for the details section of the rich presence" + "description": "Custom string for the details section of the rich presence\nIf this is set to '{null}', it will be replaced with an empty space" }, "discord.detailsDebugging": { "type": "string", "default": "Editing {filename}", - "description": "Custom string for the details section of the rich presence when debugging" + "description": "Custom string for the details section of the rich presence when debugging\nIf this is set to '{null}', it will be replaced with an empty space" }, "discord.detailsIdle": { "type": "string", @@ -78,12 +78,12 @@ "discord.lowerDetailsEditing": { "type": "string", "default": "Workspace: {workspace}", - "description": "Custom string for the state section of the rich presence" + "description": "Custom string for the state section of the rich presence\nIf this is set to '{null}', it will be replaced with an empty space" }, "discord.lowerDetailsDebugging": { "type": "string", "default": "Debugging: {workspace}", - "description": "Custom string for the state section of the rich presence when debugging" + "description": "Custom string for the state section of the rich presence when debugging\nIf this is set to '{null}', it will be replaced with an empty space" }, "discord.lowerDetailsIdle": { "type": "string", diff --git a/src/extension.ts b/src/extension.ts index 8aefa22..63b8df2 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -269,17 +269,20 @@ function generateDetails(debugging, editing, idling): string { : false; const workspaceFolder: WorkspaceFolder = checkState ? workspace.getWorkspaceFolder(window.activeTextEditor.document.uri) : null; + const emptyDebugState: boolean = config.get(debugging) === '{null}'; + const emptyEditingState: boolean = config.get(editing) === '{null}'; + return window.activeTextEditor ? debug.activeDebugSession - ? config.get(debugging) - .replace('{filename}', fileName) - .replace('{workspace}', checkState - ? workspaceFolder.name - : config.get('lowerDetailsNotFound')) - : config.get(editing) - .replace('{filename}', fileName) - .replace('{workspace}', checkState - ? workspaceFolder.name - : config.get('lowerDetailsNotFound')) + ? emptyDebugState + ? '\u200b\u200b' + : config.get(debugging) + .replace('{filename}', fileName) + .replace('{workspace}', checkState ? workspaceFolder.name : config.get('lowerDetailsNotFound')) + : emptyEditingState + ? '\u200b\u200b' + : config.get(editing) + .replace('{filename}', fileName) + .replace('{workspace}', checkState ? workspaceFolder.name : config.get('lowerDetailsNotFound')) : config.get(idling); }