* Adds command "Debug Visualizer: Use Selection as Expression" (Shift+F1)
* Changes text of command "Open a new Debug Visualizer View" to "Debug Visualizer: New View".
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
## Unrealeased
|
||||
|
||||
- Submits the expression when the expression input loses focus.
|
||||
- Changes text of command "Open a new Debug Visualizer View" to "Debug Visualizer: New View".
|
||||
- Adds command "Debug Visualizer: Use Selection as Expression" (Shift+F1)
|
||||
|
||||
## 0.13.0
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
],
|
||||
"activationEvents": [
|
||||
"onCommand:vscode-debug-visualizer.new-visualizer",
|
||||
"onCommand:vscode-debug-visualizer.visualizer-set-expression",
|
||||
"onDebug",
|
||||
"onWebviewPanel:debugVisualizer"
|
||||
],
|
||||
@@ -32,7 +33,18 @@
|
||||
"commands": [
|
||||
{
|
||||
"command": "vscode-debug-visualizer.new-visualizer",
|
||||
"title": "Open a new Debug Visualizer View"
|
||||
"title": "Debug Visualizer: New View"
|
||||
},
|
||||
{
|
||||
"command": "vscode-debug-visualizer.visualizer-set-expression",
|
||||
"title": "Debug Visualizer: Use Selection as Expression"
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
{
|
||||
"command": "vscode-debug-visualizer.visualizer-set-expression",
|
||||
"key": "shift+f1",
|
||||
"when": "editorTextFocus"
|
||||
}
|
||||
],
|
||||
"configuration": {
|
||||
|
||||
@@ -9,11 +9,13 @@ import * as open from "open";
|
||||
import chromeLauncher = require("chrome-launcher");
|
||||
import { Config } from "./Config";
|
||||
|
||||
export class ConnectionHandler {
|
||||
export class ClientConnection {
|
||||
public readonly dispose = Disposable.fn();
|
||||
@observable
|
||||
private watcher: EvaluationWatcher | undefined = undefined;
|
||||
|
||||
private readonly client: typeof debugVisualizerUIContract["TClientInterface"];
|
||||
|
||||
constructor(
|
||||
dataSource: DataSource,
|
||||
stream: WebSocketStream,
|
||||
@@ -104,6 +106,8 @@ export class ConnectionHandler {
|
||||
}
|
||||
);
|
||||
|
||||
this.client = client;
|
||||
|
||||
this.dispose.track(
|
||||
Disposable.create(
|
||||
autorun(() => {
|
||||
@@ -120,6 +124,10 @@ export class ConnectionHandler {
|
||||
this.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
public setExpression(expression: string) {
|
||||
this.client.setExpression({ expression });
|
||||
}
|
||||
}
|
||||
|
||||
async function launchChrome(url: string): Promise<boolean> {
|
||||
@@ -1,7 +1,7 @@
|
||||
import { WebSocketStream } from "@hediet/typed-json-rpc-websocket";
|
||||
import { AddressInfo } from "net";
|
||||
import WebSocket = require("ws");
|
||||
import { ConnectionHandler } from "./ConnectionHandler";
|
||||
import { ClientConnection } from "./ClientConnection";
|
||||
import * as express from "express";
|
||||
import * as http from "http";
|
||||
import * as serveStatic from "serve-static";
|
||||
@@ -14,6 +14,8 @@ export class Server {
|
||||
private server: http.Server;
|
||||
public readonly secret = cryptoRandomString({ length: 20 });
|
||||
|
||||
public readonly connections = new Set<ClientConnection>();
|
||||
|
||||
constructor(dataSource: DataSource, config: Config) {
|
||||
const app = express();
|
||||
|
||||
@@ -28,15 +30,18 @@ export class Server {
|
||||
);
|
||||
|
||||
const wss = new WebSocket.Server({ server: this.server });
|
||||
wss.on("connection", ws => {
|
||||
wss.on("connection", async ws => {
|
||||
const stream = new WebSocketStream(ws);
|
||||
new ConnectionHandler(
|
||||
const c = new ClientConnection(
|
||||
dataSource,
|
||||
stream,
|
||||
this,
|
||||
config,
|
||||
this.secret
|
||||
);
|
||||
this.connections.add(c);
|
||||
await stream.onClosed;
|
||||
this.connections.delete(c);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,11 @@ export const debugVisualizerUIContract = contract({
|
||||
newState: unchecked<DataExtractionState>(),
|
||||
}),
|
||||
}),
|
||||
setExpression: requestContract({
|
||||
params: types.type({
|
||||
expression: types.string,
|
||||
}),
|
||||
}),
|
||||
},
|
||||
server: {
|
||||
authenticate: requestContract({
|
||||
|
||||
@@ -61,6 +61,36 @@ export class Extension {
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
this.dispose.track(
|
||||
commands.registerCommand(
|
||||
"vscode-debug-visualizer.visualizer-set-expression",
|
||||
() => {
|
||||
const editor = window.activeTextEditor;
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selection = editor.selection;
|
||||
const selectedText = editor.document.getText(selection);
|
||||
|
||||
if (!selectedText) {
|
||||
return;
|
||||
}
|
||||
|
||||
const connections = [...this.server.connections.values()];
|
||||
if (connections.length > 0) {
|
||||
const latestConnection =
|
||||
connections[connections.length - 1];
|
||||
|
||||
latestConnection.setExpression(selectedText);
|
||||
} else {
|
||||
// TODO pass expression
|
||||
// this.views.createNew();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,6 +186,9 @@ export class Model {
|
||||
this.state = newState;
|
||||
}
|
||||
},
|
||||
setExpression: async ({ expression }) => {
|
||||
this.setExpression(expression);
|
||||
},
|
||||
}
|
||||
);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user