test resolver: simplify pause/unpause
This commit is contained in:
parent
4f4d12148f
commit
99f4201e20
2 changed files with 39 additions and 10 deletions
|
@ -23,7 +23,8 @@
|
|||
"onCommand:vscode-testresolver.newWindowWithError",
|
||||
"onCommand:vscode-testresolver.showLog",
|
||||
"onCommand:vscode-testresolver.openTunnel",
|
||||
"onCommand:vscode-testresolver.startRemoteServer"
|
||||
"onCommand:vscode-testresolver.startRemoteServer",
|
||||
"onCommand:vscode-testresolver.toggleConnectionPause"
|
||||
],
|
||||
"main": "./out/extension",
|
||||
"devDependencies": {
|
||||
|
@ -70,9 +71,14 @@
|
|||
"command": "vscode-testresolver.openTunnel"
|
||||
},
|
||||
{
|
||||
"title": "Open Remote Server...",
|
||||
"title": "Open a Remote Port...",
|
||||
"category": "Remote-TestResolver",
|
||||
"command": "vscode-testresolver.startRemoteServer"
|
||||
},
|
||||
{
|
||||
"title": "Pause Connection (Test Reconnect)",
|
||||
"category": "Remote-TestResolver",
|
||||
"command": "vscode-testresolver.toggleConnectionPause"
|
||||
}
|
||||
],
|
||||
"menus": {
|
||||
|
@ -84,6 +90,10 @@
|
|||
{
|
||||
"command": "vscode-testresolver.startRemoteServer",
|
||||
"when": "remoteName == test"
|
||||
},
|
||||
{
|
||||
"command": "vscode-testresolver.toggleConnectionPause",
|
||||
"when": "remoteName == test"
|
||||
}
|
||||
],
|
||||
"statusBar/remoteIndicator": [
|
||||
|
@ -111,6 +121,11 @@
|
|||
"command": "vscode-testresolver.startRemoteServer",
|
||||
"when": "remoteName == test",
|
||||
"group": "remote_90_test_2_more@5"
|
||||
},
|
||||
{
|
||||
"command": "vscode-testresolver.toggleConnectionPause",
|
||||
"when": "remoteName == test",
|
||||
"group": "remote_90_test_2_more@6"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -126,11 +141,6 @@
|
|||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"testresolver.pause": {
|
||||
"description": "If set, connection is paused",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"testresolver.supportPublicPorts": {
|
||||
"description": "If set, the test resolver tunnel factory will support mock public ports. Forwarded ports will not actually be public. Requires reload.",
|
||||
"type": "boolean",
|
||||
|
|
|
@ -135,9 +135,9 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
let remoteReady = true, localReady = true;
|
||||
const remoteSocket = net.createConnection({ port: serverAddr.port });
|
||||
|
||||
let isDisconnected = getConfiguration('pause') === true;
|
||||
vscode.workspace.onDidChangeConfiguration(_ => {
|
||||
let newIsDisconnected = getConfiguration('pause') === true;
|
||||
let isDisconnected = connectionPaused;
|
||||
connectionPausedEvent.event(_ => {
|
||||
let newIsDisconnected = connectionPaused;
|
||||
if (isDisconnected !== newIsDisconnected) {
|
||||
outputChannel.appendLine(`Connection state: ${newIsDisconnected ? 'open' : 'paused'}`);
|
||||
isDisconnected = newIsDisconnected;
|
||||
|
@ -215,6 +215,9 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
});
|
||||
}
|
||||
|
||||
let connectionPaused = false;
|
||||
let connectionPausedEvent = new vscode.EventEmitter<boolean>();
|
||||
|
||||
const authorityResolverDisposable = vscode.workspace.registerRemoteAuthorityResolver('test', {
|
||||
async getCanonicalURI(uri: vscode.Uri): Promise<vscode.Uri> {
|
||||
return vscode.Uri.file(uri.path);
|
||||
|
@ -258,6 +261,22 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
}
|
||||
}));
|
||||
|
||||
const pauseStatusBarEntry = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
||||
pauseStatusBarEntry.text = 'Remote connection paused. Click to undo';
|
||||
pauseStatusBarEntry.command = 'vscode-testresolver.toggleConnectionPause';
|
||||
pauseStatusBarEntry.backgroundColor = new vscode.ThemeColor('statusBarItem.errorBackground');
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-testresolver.toggleConnectionPause', () => {
|
||||
if (!connectionPaused) {
|
||||
connectionPaused = true;
|
||||
pauseStatusBarEntry.show();
|
||||
} else {
|
||||
connectionPaused = false;
|
||||
pauseStatusBarEntry.hide();
|
||||
}
|
||||
connectionPausedEvent.fire(connectionPaused);
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('vscode-testresolver.openTunnel', async () => {
|
||||
const result = await vscode.window.showInputBox({
|
||||
prompt: 'Enter the remote port for the tunnel',
|
||||
|
|
Loading…
Reference in a new issue