feat: debug support
This commit is contained in:
parent
73a0f509db
commit
fafd567cde
1 changed files with 21 additions and 6 deletions
|
@ -10,7 +10,9 @@ import {
|
||||||
workspace,
|
workspace,
|
||||||
TextDocument,
|
TextDocument,
|
||||||
TextDocumentChangeEvent,
|
TextDocumentChangeEvent,
|
||||||
Disposable
|
Disposable,
|
||||||
|
debug,
|
||||||
|
DebugSession
|
||||||
} from 'vscode';
|
} from 'vscode';
|
||||||
const languages = require('./data/languages.json');
|
const languages = require('./data/languages.json');
|
||||||
|
|
||||||
|
@ -95,7 +97,10 @@ function initRPC(clientID: string): void {
|
||||||
setTimeout(() => rpc.setActivity(activity), 500);
|
setTimeout(() => rpc.setActivity(activity), 500);
|
||||||
eventHandlers.add(workspace.onDidChangeTextDocument((e: TextDocumentChangeEvent) => setActivity()))
|
eventHandlers.add(workspace.onDidChangeTextDocument((e: TextDocumentChangeEvent) => setActivity()))
|
||||||
.add(workspace.onDidOpenTextDocument((e: TextDocument) => setActivity()))
|
.add(workspace.onDidOpenTextDocument((e: TextDocument) => setActivity()))
|
||||||
.add(workspace.onDidCloseTextDocument((e: TextDocument) => setActivity()));
|
.add(workspace.onDidCloseTextDocument((e: TextDocument) => setActivity()))
|
||||||
|
.add(debug.onDidChangeActiveDebugSession((e: DebugSession) => setActivity()))
|
||||||
|
.add(debug.onDidStartDebugSession((e: DebugSession) => setActivity()))
|
||||||
|
.add(debug.onDidTerminateDebugSession((e: DebugSession) => setActivity()));
|
||||||
// Make sure to listen to the close event and dispose and destroy everything accordingly.
|
// Make sure to listen to the close event and dispose and destroy everything accordingly.
|
||||||
rpc.transport.once('close', () => {
|
rpc.transport.once('close', () => {
|
||||||
if (!config.get('enabled')) return;
|
if (!config.get('enabled')) return;
|
||||||
|
@ -155,7 +160,9 @@ function setActivity(): void {
|
||||||
lastKnownFileName = window.activeTextEditor ? window.activeTextEditor.document.fileName : null;
|
lastKnownFileName = window.activeTextEditor ? window.activeTextEditor.document.fileName : null;
|
||||||
|
|
||||||
const details = window.activeTextEditor
|
const details = window.activeTextEditor
|
||||||
? config.get('details').replace('{filename}', basename(window.activeTextEditor.document.fileName))
|
? debug.activeDebugSession
|
||||||
|
? `${config.get('details').replace('{filename}', basename(window.activeTextEditor.document.fileName))} (Debug)`
|
||||||
|
: config.get('details').replace('{filename}', basename(window.activeTextEditor.document.fileName))
|
||||||
: config.get('detailsIdle');
|
: config.get('detailsIdle');
|
||||||
const checkState = window.activeTextEditor
|
const checkState = window.activeTextEditor
|
||||||
? Boolean(workspace.getWorkspaceFolder(window.activeTextEditor.document.uri))
|
? Boolean(workspace.getWorkspaceFolder(window.activeTextEditor.document.uri))
|
||||||
|
@ -180,11 +187,19 @@ function setActivity(): void {
|
||||||
details,
|
details,
|
||||||
state,
|
state,
|
||||||
startTimestamp: new Date().getTime() / 1000,
|
startTimestamp: new Date().getTime() / 1000,
|
||||||
largeImageKey: largeImageKey ? largeImageKey.image || largeImageKey : 'txt',
|
largeImageKey: largeImageKey
|
||||||
|
? largeImageKey.image
|
||||||
|
|| largeImageKey
|
||||||
|
: 'txt',
|
||||||
largeImageText: window.activeTextEditor
|
largeImageText: window.activeTextEditor
|
||||||
? config.get('largeImage') || window.activeTextEditor.document.languageId
|
? config.get('largeImage')
|
||||||
|
|| window.activeTextEditor.document.languageId
|
||||||
: config.get('largeImageIdle'),
|
: config.get('largeImageIdle'),
|
||||||
smallImageKey: env.appName.includes('Insiders') ? 'vscode-insiders' : 'vscode',
|
smallImageKey: debug.activeDebugSession
|
||||||
|
? 'debug'
|
||||||
|
: env.appName.includes('Insiders')
|
||||||
|
? 'vscode-insiders'
|
||||||
|
: 'vscode',
|
||||||
smallImageText: config.get('smallImage').replace('{appname}', env.appName),
|
smallImageText: config.get('smallImage').replace('{appname}', env.appName),
|
||||||
instance: false
|
instance: false
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue