TheMast
TheMast

Reputation: 103

A method to expose the VSCode active 'when Clause Contexts'

I'm searching for a method to expose VSCode active 'when Clause Contexts' e.g 'explorerResourceIsFolder'. To give you a better understanding of my use case, here's some background on the project to which a VSCode extension is being developed. My extension will facilitate programming in and controlling VSCode by voice.

Caster is a Dragonfly-Based Voice Programming Toolkit. Dragonfly is a speech recognition framework. It is a Python package which offers a high-level object model and allows its users to easily write scripts, macros, and programs which use speech recognition. The goal behind these projects is to enable those who limited interaction with keyboard or mouse to program or for Devs to boost productivity.

Some current outstanding limitations with Caster and Dragonfly both interact by emulating keystrokes. This is just to name a few issues.

Some examples via Adom editor

  1. find in buffer": R(Key("c-f"), rdescript="Atom: Find in Buffer") Only a few relevant commands are useful within 'Find in Buffer' context, but Caster commands are global which decreases command speech recognition accuracy and increases grammar complexity. With Caster IDE integration would allow for llimited command sets specified to IDE contexts or focuses.
  2. "split into lines": R(Key("cs-p") + Text("Split Into Lines") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Split Into lines"), Not all IDE functions can be called via shortcuts or be easily re-created within Caster. My attempt to work around this within adom was to utilize command palette. While this extended my ability to trigger commands it introduced latency. To fast the wrong command would be triggered. Too slow it a decrease productivity. Indexing latency which based on system load, system specs, number of active plug-ins, and number of characters per command. We tried to mitigate this by using Pause(atom_palette_wait) but the variables in the latency were too complex. The same would be true of Studio Code.

Caster framework IDE integration

IDEs plug-ins/extensions framework


There will be three parts to the Studio Code Extension.

  1. A websocket running a server and client that allows for bidirectional communication to Caster.
  2. A function that executes 'Command_id' e.g 'editor.debug.action.toggleBreakpoint' In progress - Near completion
  3. A method to expose the editors 'when Clause Contexts' e.g 'explorerResourceIsFolder' - Searching for method - No luck via the APIs thus far - Searching source code to understand implementation.

Any suggestions would be welcome. If you think this is worth opening a github ticket on the VSCode repository let me know.

Upvotes: 6

Views: 1662

Answers (1)

Yemi Bedu
Yemi Bedu

Reputation: 312

There is a non public api for getting the when context in effect. You can use getValue(key: string). It is available from the work on this issue ticket:

Lift setContext from a command to proper API Microsoft/vscode#10471

and the source can be viewed here:

contextKeyService.ts

by using getValue(key: string)

It is still work in progress as of May 2017. Thank you. Good day.

Upvotes: 5

Related Questions