๐Ÿ“ฆ hediet / vscode-rpc

Provides an RPC interface to automate VSCode from other processes

โ˜… 11 stars โ‘‚ 1 forks ๐Ÿ‘ 11 watching
๐Ÿ“ฅ Clone https://github.com/hediet/vscode-rpc.git
HTTPS git clone https://github.com/hediet/vscode-rpc.git
SSH git clone git@github.com:hediet/vscode-rpc.git
CLI gh repo clone hediet/vscode-rpc
Henning Dieterichs Henning Dieterichs Implements `cursorSelectionsChanged` event for editor contract. 015b094 6 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ .vscode
๐Ÿ“ docs
๐Ÿ“ example-client
๐Ÿ“ extension
๐Ÿ“ vscode-rpc
๐Ÿ“„ .gitignore
๐Ÿ“„ .prettierrc.json
๐Ÿ“„ README.md
๐Ÿ“„ tslint.json
๐Ÿ“„ README.md

VS Code RPC

This repository contains an RPC Server for VS Code (implemented as extension) and a NodeJS client implementation.

Scenarios

See contracts.ts for the RPC contract definitions.

Registrar

To support controlling multiple Vs Code instances, there is a registrar-server process that is connected to all VS Code instances and to all clients. This server broadcasts notifications from clients to VsCode instances and vice versa and listens on a fixed port.

Each VS Code instance has a connection to the registrar server and hosts its own server on a random port. The registrar server can be asked to get a list of all available Vs Code instances and their server ports. The registrar server is also responsible for authenticating clients.

The first Vs Code instance spawns the registrar and the registrar exits with the disconnect of the last Vs Code client as shown in the folling sequence diagram:

Registrar Startup

VS Code Instances

After ensuring that the registrar has started, each VS Code instance authenticates to the registrar server:

VsCode Authentication

Tokens

Authentication is implemented using tokens. Tokens are managed by the registrar. Prior to issueing a new token, the registrar asks all VS Code instances to grant or deny the token request:

Token Request

Client Authentication

Clients must authenticate to the registrar before send any requests or notifications:

Client Authenticates to Registrar

If clients connect to a VS Code instance directly, they also have to authenticate:

Client Authenticates to VSCode