diff --git a/src/extension.ts b/src/extension.ts index 5f0902d..d4d1d22 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -4,7 +4,7 @@ import { loadConfigs } from './config'; import type { Connection } from './connection'; import type { FileSystemConfig } from './fileSystemConfig'; import { FileSystemRouter } from './fileSystemRouter'; -import { Logging } from './logging'; +import { Logging, setDebug } from './logging'; import { Manager } from './manager'; import type { SSHPseudoTerminal } from './pseudoTerminal'; import { ConfigTreeProvider, ConnectionTreeProvider } from './treeViewManager'; @@ -27,7 +27,9 @@ interface CommandHandler { } export function activate(context: vscode.ExtensionContext) { - Logging.info(`Extension activated, version ${getVersion()}`); + Logging.info(`Extension activated, version ${getVersion()}, mode ${context.extensionMode}`); + + setDebug(context.extensionMode !== vscode.ExtensionMode.Production); // Really too bad we *need* the ExtensionContext for relative resources // I really don't like having to pass context to *everything*, so let's do it this way diff --git a/src/logging.ts b/src/logging.ts index 9775f3c..0200f49 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -2,10 +2,11 @@ import * as vscode from 'vscode'; import type { FileSystemConfig } from './fileSystemConfig'; // Since the Extension Development Host runs with debugger, we can use this to detect if we're debugging -export const DEBUG: number | undefined = process.execArgv.find(a => a.includes('--inspect')) ? 3000 : undefined; - -if (DEBUG) { - console.warn('[vscode-sshfs] Detected we are running in debug mode'); +export let DEBUG: boolean = false; +export function setDebug(debug: boolean) { + console.warn(`[vscode-sshfs] Debug mode set to ${debug}`); + DEBUG = debug; + if (!debug) return; import('source-map-support/register').catch(e => console.warn('Could not register source-map-support:', e)); } diff --git a/src/settings.ts b/src/settings.ts index 9d644ee..42610a7 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -4,7 +4,7 @@ import * as path from 'path'; import * as vscode from 'vscode'; import { deleteConfig, loadConfigsRaw, updateConfig } from './config'; import { getLocations } from './fileSystemConfig'; -import { Logging, DEBUG, LOGGING_NO_STACKTRACE } from './logging'; +import { DEBUG, Logging, LOGGING_NO_STACKTRACE } from './logging'; import { toPromise } from './toPromise'; import type { Message, Navigation } from './webviewMessages'; @@ -18,7 +18,7 @@ function getExtensionPath(): string | undefined { async function getDebugContent(): Promise { if (!DEBUG) return false; - const URL = `http://localhost:${DEBUG}/`; + const URL = `http://localhost:3000/`; const http = await import('http'); return toPromise(cb => http.get(URL, async (message) => { if (message.statusCode !== 200) return cb(new Error(`Error code ${message.statusCode} (${message.statusMessage}) connecting to React dev server}`));