Make use of ExtensionContext.extensionMode

feature/ssh-config
Kelvin Schoofs 4 years ago
parent 4caa62df0f
commit 4a7b456451

@ -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

@ -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));
}

@ -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<string | false> {
if (!DEBUG) return false;
const URL = `http://localhost:${DEBUG}/`;
const URL = `http://localhost:3000/`;
const http = await import('http');
return toPromise<string>(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}`));

Loading…
Cancel
Save