cursorless-dev / cursorless Goto Github PK
View Code? Open in Web Editor NEWDon't let the cursor slow you down
Home Page: https://www.cursorless.org/
License: MIT License
Don't let the cursor slow you down
Home Page: https://www.cursorless.org/
License: MIT License
Would it be possible to add a "type" transformation? In TypeScript, for example:
const logs: { user: string; event: string }[] = [];
I think being able to "take type" and select { user: string; event: string }[]
it would be very useful.
Less important imo, but there are also the cases of generics and type parameters to consider?
Eg "replace fine with camel hello world". It would support arbitrary format string ie "replace <target>
with <format_string>
". The actual replaceWith
function would accept a list of strings so that it can operate on compound targets. So talon-side we could support "replace fine and bar with camel hello world and snake hello there".
Could also support things other than format strings after the "with", eg "spell <letters>
" or "word" or "round" / "curly" / "square" that would return eg ["(", ")"]
, to combine with "boundary", allowing commands like "replace border round with square"
It is tempting to support cursorless targets after the "with" as well, eg "replace fine with gust", but this functionality is subsumed by "bring", eg "bring gust to fine", so not sure it's worth the added complexity
Useful if the mark is "here", eg for "quad wrap token"
For example in the following code:
interface Foo {
bar: Bar;
baz: Baz;
}
If your cursor was before bar
, then "take field" would select bar: Bar
Look for the property_signature
node type
A couple options:
foo.bar
), and class property definitionsSee:
https://code.visualstudio.com/api/working-with-extensions/continuous-integration
https://github.com/microsoft/vscode-test/blob/main/sample/azure-pipelines.yml
add black checker for python code
add isort for python code
use version bump script bump major --tag --push
from bump as an action like in semver-release-action
Dismiss stale reviews
Add code owners?
VSCode has support for snippets that can take a selection. We'd like to use this to enable things such as "if state wrap air", "try state wrap air", etc
We propose to add a new action. Check out simple actions like ExtractVariable
as a starting point.
The action will call editor.insertSnippet
.
We will keep language-specific snippets for each syntactic scope type, similar to how we do for finding containing scope; see eg https://github.com/pokey/cursorless-vscode/blob/fdebfe93c7871a3e3bf832532f51cf64b8f3c3a8/src/languages/python.ts#L46-L68 Note that the snippet will leverage TM_SELECTED_TEXT
to refer to where the target that is wrapped will go. We can add tabstops for things like if statement guard, catch block, etc
The action will take an extra arg which is the scopetype to wrap with, eg ifStatement
. See Wrap
for example of taking extra args
Add a new capture like "wrap" that accepts a scope type. Something like "<scopeType> wrap <target>"
Cursorless should understand that subwords in a token are a sequence, and know how to insert / remove delimiters. For camel case it should properly figure out when to upper / lower case
For some reason the function transformation in Typescript doesn't work when the function has "export default"
If a command, eg "chuck" is about to delete something you can't see, it should either fail or warn. Could have a setting to turn this one off if you like to live dangerously ๐
This protection would be important to have before we support #44
Fwiw this support could prob be implemented by a separate extension that Cursorless could then be a client of if it wanted to do something special
Here's some code to get us started. Was originally in extension.ts
, but removed as part of #1035 as it is still just unused draft code:
function checkForEditsOutsideViewport(
event: vscode.TextDocumentChangeEvent
) {
// TODO: Only activate this code during the course of a cursorless action
// Can register pre/post command hooks the way we do with test case recorder
// TODO: Move this thing to a graph component
// TODO: Need to move command executor and test case recorder to graph
// component while we're doing this stuff so it's easier to register the
// hooks
// TODO: Should run this code even if document is not in a visible editor
// as long as we are during the course of a cursorless command.
const editor = vscode.window.activeTextEditor;
if (
editor == null ||
editor.document !== event.document ||
event.reason === vscode.TextDocumentChangeReason.Undo ||
event.reason === vscode.TextDocumentChangeReason.Redo
) {
return;
}
const ranges = event.contentChanges
.filter(
(contentChange) =>
!editor.visibleRanges.some(
(visibleRange) =>
contentChange.range.intersection(visibleRange) != null
)
)
.map(({ range }) => range);
if (ranges.length > 0) {
ranges.sort((a, b) => a.start.line - b.start.line);
const linesText = ranges
.map((range) => `${range.start.line + 1}-${range.end.line + 1}`)
.join(", ");
vscode.window.showWarningMessage(
`Modification outside of viewport at lines: ${linesText}`
);
}
}
vscode.workspace.onDidChangeTextDocument(checkForEditsOutsideViewport)
Eg name of var in a declaration, class name, function name, etc. Could be extended to support specifying "funk name", "class name", etc. So eg
class Foo:
def bar():
baz = 5
If your cursor is on the 5
, then:
baz
,baz
,bar
, andFoo
Today we just support "refactor.extract.constant"
, but there are many more such as converting a lambda function to add braces etc
We can probably just let user define these in user space, but we should add a few to a Recipe page on wiki and link there from customization doc
i haven't had a chance to dig into this yet, but parse tree appears to be non-functional on windows at the moment
from the extension log:
[2021-05-10 16:23:45.226] [exthost] [error] Activating extension pokey.parse-tree failed due to an error:
[2021-05-10 16:23:45.227] [exthost] [error] Error: \\?\c:\Users\knaus\.vscode\extensions\pokey.parse-tree-0.2.0\node_modules\tree-sitter\build\Release\tree_sitter_runtime_binding.node is not a valid Win32 application.
\\?\c:\Users\knaus\.vscode\extensions\pokey.parse-tree-0.2.0\node_modules\tree-sitter\build\Release\tree_sitter_runtime_binding.node
at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1812)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1250:18)
at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1812)
at Module.load (internal/modules/cjs/loader.js:1039:32)
at Module._load (internal/modules/cjs/loader.js:932:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
at Function.o._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:27791)
at Function.E._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:24509)
at Function.a._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:59194)
at Module.require (internal/modules/cjs/loader.js:1079:19)
at v (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:694)
at Object.<anonymous> (c:\Users\knaus\.vscode\extensions\pokey.parse-tree-0.2.0\node_modules\tree-sitter\index.js:3:13)
at Module.u._compile (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:1248)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1039:32)
at Module._load (internal/modules/cjs/loader.js:932:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
at Function.o._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:27791)
at Function.E._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:24509)
at Function.a._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:59194)
at Module.require (internal/modules/cjs/loader.js:1079:19)
at v (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:694)
at Object.<anonymous> (c:\Users\knaus\.vscode\extensions\pokey.parse-tree-0.2.0\out\extension.js:14:16)
at Module.u._compile (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:1248)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1039:32)
at Module._load (internal/modules/cjs/loader.js:932:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
at Function.o._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:27791)
at Function.E._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:24509)
at Function.a._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:59194)
at Module.require (internal/modules/cjs/loader.js:1079:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Function.t [as __$__nodeRequire] (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:5:101)
at h._loadCommonJSModule (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:25918)
at h._doActivateExtension (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:12016)
at h._activateExtension (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:11072)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2021-05-10 16:23:45.453] [exthost] [info] ExtensionService#_doActivateExtension vscode.github {"startup":true,"extensionId":{"value":"vscode.github","_lower":"vscode.github"},"activationEvent":"*"}
[2021-05-10 16:23:45.453] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/github/dist/extension.js
[2021-05-10 16:23:45.459] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode.js-debug {"startup":false,"extensionId":{"value":"ms-vscode.js-debug","_lower":"ms-vscode.js-debug"},"activationEvent":"onCommand:extension.js-debug.clearAutoAttachVariables"}
[2021-05-10 16:23:45.459] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/ms-vscode.js-debug/src/extension.js
[2021-05-10 16:23:45.535] [exthost] [info] ExtensionService#_doActivateExtension ms-python.python {"startup":false,"extensionId":{"value":"ms-python.vscode-pylance","_lower":"ms-python.vscode-pylance"},"activationEvent":"onLanguage:python"}
[2021-05-10 16:23:45.535] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/knaus/.vscode/extensions/ms-python.python-2021.4.765268190/out/client/extension
[2021-05-10 16:23:45.648] [exthost] [info] eager extensions activated
[2021-05-10 16:23:45.677] [exthost] [info] ExtensionService#_doActivateExtension vscode.github-authentication {"startup":false,"extensionId":{"value":"vscode.github-authentication","_lower":"vscode.github-authentication"},"activationEvent":"onAuthenticationRequest:github"}
[2021-05-10 16:23:45.677] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/github-authentication/dist/extension.js
[2021-05-10 16:23:45.686] [exthost] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":false,"extensionId":{"value":"vscode.emmet","_lower":"vscode.emmet"},"activationEvent":"onStartupFinished"}
[2021-05-10 16:23:45.686] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/emmet/dist/node/emmetNodeMain
[2021-05-10 16:23:45.693] [exthost] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":false,"extensionId":{"value":"vscode.merge-conflict","_lower":"vscode.merge-conflict"},"activationEvent":"onStartupFinished"}
[2021-05-10 16:23:45.693] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/merge-conflict/dist/mergeConflictMain
[2021-05-10 16:23:45.697] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-wsl-recommender {"startup":false,"extensionId":{"value":"ms-vscode-remote.remote-wsl-recommender","_lower":"ms-vscode-remote.remote-wsl-recommender"},"activationEvent":"onStartupFinished"}
[2021-05-10 16:23:45.697] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/ms-vscode-remote.remote-wsl-recommender/dist/extension.js
[2021-05-10 16:23:45.704] [exthost] [info] ExtensionService#_doActivateExtension vscode.testing-editor-contributions {"startup":false,"extensionId":{"value":"vscode.testing-editor-contributions","_lower":"vscode.testing-editor-contributions"},"activationEvent":"onStartupFinished"}
[2021-05-10 16:23:45.704] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/testing-editor-contributions/dist/extension.js
[2021-05-10 16:23:45.707] [exthost] [info] ExtensionService#_doActivateExtension dbaeumer.vscode-eslint {"startup":false,"extensionId":{"value":"dbaeumer.vscode-eslint","_lower":"dbaeumer.vscode-eslint"},"activationEvent":"onStartupFinished"}
[2021-05-10 16:23:45.707] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/knaus/.vscode/extensions/dbaeumer.vscode-eslint-2.1.20/client/out/extension
[2021-05-10 16:23:45.714] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-wsl {"startup":false,"extensionId":{"value":"ms-vscode-remote.remote-wsl","_lower":"ms-vscode-remote.remote-wsl"},"activationEvent":"onStartupFinished"}
[2021-05-10 16:23:45.714] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/knaus/.vscode/extensions/ms-vscode-remote.remote-wsl-0.54.6/dist/extension
[2021-05-10 16:23:45.979] [exthost] [info] ExtensionService#_doActivateExtension ms-python.vscode-pylance {"startup":false,"extensionId":{"value":"ms-python.vscode-pylance","_lower":"ms-python.vscode-pylance"},"activationEvent":"onLanguage:python"}
[2021-05-10 16:23:45.979] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/knaus/.vscode/extensions/ms-python.vscode-pylance-2021.4.3/dist/extension.bundle.js
[2021-05-10 16:24:27.651] [exthost] [info] extension host terminating: received terminate message from renderer
[2021-05-10 16:24:28.671] [exthost] [info] exiting with code 0
[2021-05-10 16:24:28.907] [exthost] [info] extension host started
[2021-05-10 16:24:28.976] [exthost] [info] ExtensionService#_doActivateExtension vscode.microsoft-authentication {"startup":false,"extensionId":{"value":"vscode.microsoft-authentication","_lower":"vscode.microsoft-authentication"},"activationEvent":"onAuthenticationRequest:microsoft"}
[2021-05-10 16:24:28.976] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/microsoft-authentication/dist/extension.js
[2021-05-10 16:24:28.984] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-auto-launch {"startup":true,"extensionId":{"value":"vscode.debug-auto-launch","_lower":"vscode.debug-auto-launch"},"activationEvent":"*"}
[2021-05-10 16:24:28.984] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/debug-auto-launch/dist/extension
[2021-05-10 16:24:28.986] [exthost] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"extensionId":{"value":"vscode.github","_lower":"vscode.github"},"activationEvent":"*"}
[2021-05-10 16:24:28.986] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Program Files/Microsoft VS Code/resources/app/extensions/git/dist/main
[2021-05-10 16:24:28.999] [exthost] [info] ExtensionService#_doActivateExtension pokey.command-server {"startup":true,"extensionId":{"value":"pokey.command-server","_lower":"pokey.command-server"},"activationEvent":"*"}
[2021-05-10 16:24:28.999] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/knaus/.vscode/extensions/pokey.command-server-0.3.4/out/extension.js
[2021-05-10 16:24:29.002] [exthost] [info] ExtensionService#_doActivateExtension pokey.parse-tree {"startup":true,"extensionId":{"value":"pokey.cursorless","_lower":"pokey.cursorless"},"activationEvent":"*"}
[2021-05-10 16:24:29.002] [exthost] [info] ExtensionService#loadCommonJSModule file:///c:/Users/knaus/.vscode/extensions/pokey.parse-tree-0.2.0/out/extension.js
[2021-05-10 16:24:29.008] [exthost] [error] Activating extension pokey.parse-tree failed due to an error:
[2021-05-10 16:24:29.009] [exthost] [error] Error: \\?\c:\Users\knaus\.vscode\extensions\pokey.parse-tree-0.2.0\node_modules\tree-sitter\build\Release\tree_sitter_runtime_binding.node is not a valid Win32 application.
\\?\c:\Users\knaus\.vscode\extensions\pokey.parse-tree-0.2.0\node_modules\tree-sitter\build\Release\tree_sitter_runtime_binding.node
at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1812)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1250:18)
at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1812)
at Module.load (internal/modules/cjs/loader.js:1039:32)
at Module._load (internal/modules/cjs/loader.js:932:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
at Function.o._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:27791)
at Function.E._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:24509)
at Function.a._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:59194)
at Module.require (internal/modules/cjs/loader.js:1079:19)
at v (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:694)
at Object.<anonymous> (c:\Users\knaus\.vscode\extensions\pokey.parse-tree-0.2.0\node_modules\tree-sitter\index.js:3:13)
at Module.u._compile (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:1248)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1039:32)
at Module._load (internal/modules/cjs/loader.js:932:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
at Function.o._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:27791)
at Function.E._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:24509)
at Function.a._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:59194)
at Module.require (internal/modules/cjs/loader.js:1079:19)
at v (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:694)
at Object.<anonymous> (c:\Users\knaus\.vscode\extensions\pokey.parse-tree-0.2.0\out\extension.js:14:16)
at Module.u._compile (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:4:1248)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1039:32)
at Module._load (internal/modules/cjs/loader.js:932:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
at Function.o._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:27791)
at Function.E._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:24509)
at Function.a._load (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:59194)
at Module.require (internal/modules/cjs/loader.js:1079:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Function.t [as __$__nodeRequire] (c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js:5:101)
at h._loadCommonJSModule (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:105:25918)
at h._doActivateExtension (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:12016)
at h._activateExtension (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:91:11072)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Promise.all (index 3)
at async Promise.all (index 0)
We'd like to support the "matching" modifier, which looks for the nearest paired symbol, such as "
, (
, [
, etc, and selects until past the matching symbol, similar to the vim %
motion
We also may want a version where you specify which paired token to look for, eg "round", "square", etc
This issue will be implemented by layering on top of #13 by making it synonymous with "past next pair"
It would be considered a delimited sequence, so that it would remove trailing periods as necessary. We probably want to use an NLP library for this one to do it properly
sentence-splitter
might be worth investigatingIt would be nice to have something hooked up to cursorless.toggleDecorations
by default.
Edit (@pokey): We've decided to just add instructions for how to set up your own voice command for this to the wiki under FAQ and recipes
We think we should probably just call both "item"
. This allows for us to use the word "element"
for html elements.
For example "take third word" in the word fooBarBaz
yields:
Cannot read property 'end' of undefined
Of course one could say "take last word" instead, which does work.
Full trace from the extension host:
[2021-06-22 11:54:18.382] [exthost] [error] TypeError: Cannot read property 'end' of undefined
at xv (/home/brock/.vscode/extensions/pokey.cursorless-0.14.0/dist/extension.js:23:9154)
at /home/brock/.vscode/extensions/pokey.cursorless-0.14.0/dist/extension.js:23:7738
at Array.map (<anonymous>)
at as (/home/brock/.vscode/extensions/pokey.cursorless-0.14.0/dist/extension.js:23:7731)
at $c (/home/brock/.vscode/extensions/pokey.cursorless-0.14.0/dist/extension.js:23:6721)
at /home/brock/.vscode/extensions/pokey.cursorless-0.14.0/dist/extension.js:23:6551
at Array.map (<anonymous>)
at ss (/home/brock/.vscode/extensions/pokey.cursorless-0.14.0/dist/extension.js:23:6544)
at /home/brock/.vscode/extensions/pokey.cursorless-0.14.0/dist/extension.js:23:12407
at E._executeContributedCommand (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:87:107932)
at E._doExecuteCommand (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:87:107077)
at E.executeCommand (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:87:106983)
at Object.executeCommand (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:96:21346)
at CommandRunner.<anonymous> (/home/brock/.vscode/extensions/pokey.command-server-0.5.1/out/commandRunner.js:76:56)
at Generator.next (<anonymous>)
at fulfilled (/home/brock/.vscode/extensions/pokey.command-server-0.5.1/out/commandRunner.js:5:58) cursorless.command
For example:
See https://github.com/pokey/cursorless-vscode/wiki/Target-overhaul for many more examples
every funk
and first char
/ last word
etcfirst past third word
or the future first past third funk
?Cycles through homophones
Should preserve capitalization
Should set quick action as well when that is supported
Approach:
getText
action to get text of target back to talonreplace
action (once supported) to insert next phoneEg "join line air past bat". If applied to single line, should prob join with next line, like in vim / vscode.
Could prob use this as a way to remove an empty line after given line?
Could initially implement using setSelection followed by built-in vscode join command
Support specifying thing to join them with, eg ","
?
We'd like to support transformations such as "outer round" to take everything inside and including the parentheses containing a token, as well as "inner round", "inner square", etc.
Would also be nice to support selecting the delimiter symbols themselves, eg the open and close paren. This could be eg "border round", "border square", etc. Or "disc", or "doughnut", or "bound" or something. This version of the transformation would be useful when combined with a list-based "replace with" command, so could say eg "replace border round with square" to change enclosing parens to square brackets.
Eg "take air last three chars" or "take bat first two words"
When issuing a command such as "chuck gust past end of line", cursorless incorrectly assumes that "end of line" refers to the current cursor line rather than the line containing "gust".
Only occurs if you pick a range from the second token to the first
If you have 5 cursors, you could say "insert range 1 to 5 pre this". For example, if you have a cursor at the beginning of each of these lines:
foo
bar
baz
bongo
Then saying "insert range 1 to 4 pre this", you'd get the following:
1foo
2bar
3baz
4bongo
Probably talon would just send a list to vscode, which would then zip it with the targets as normal. So the range would just operate like "square" etc as described in #15
Could also have a simplified version which is just "insert count pre this", or "insert count from two pre this", and it would count as necessary
Could also do alphabet ranges
This one uses the language server to find actual references, rather than the purely textual operation of #29
Eg "take fine first character". Currently supported in the grammar but not yet implemented. Start here for implementation: https://github.com/pokey/cursorless-vscode/blob/974c91ba2d5341c35b29918a78f9dfc1164788ae/src/processTargets.ts#L198-L238
To be consistent with the way we infer the type of a start of a range based on the type of the end of the range, we could infer the type of the first swap argument from the type of the second argument. For example, "swap with funk gust", can infer that the first argument is the function containing the cursor.
I believe the following actions fit into a common framework:
I believe they fall along a couple axes:
Edit mode / source | Modify token itself | Insert before / after token |
---|---|---|
Formatter output (eg "camel hello world") | "replace with" / "change to" | "add" / "insert" / "type" |
Move cursor to edit | "clear" | "drink" / "pour" / "add"? |
From another target | "bring" / "move" | "bring" / "move" |
From the clipboard | "paste" | "paste" |
Converting a list to a dict, keys from dict into a list, etc
Was thinking this could be interesting when combined with #46, because then you could apply a transformation to something and then insert it in some specific file, recreating some of the functionality of https://github.com/plopjs/plop
Can use the built-in vscode command revealLine
as defined on this page
Eg "take row 5" to select the fifth line
Note that relative line numbers would be covered by #13
Cursorless has no way to store a reference to a target for future use. The most obvious use case for this functionality is basic bookmarking, where a user can create a short name for a location in a document to jump back to later.
However, this basic functionality only scratches the surface of what can be done using an operation that creates a named reference to a cursorless target. There are two main aspects to cursorless that makes this type of bookmark far more powerful than what can be done using a simple bookmarking library.
The first component is that cursorless supports many different actions. The basic operation of jumping back to a bookmark as described at the top of this issue can be accomplished by issuing the "take"
action on the book mark. Even this operation, though, is likely more powerful than with a traditional bookmarks library, because it can be used to restore an exact set of selections, and these selections will be updated even as the document evolves.
However, these bookmarks can also be referred to without ever jumping to them. For example, a user could book mark a location in a file and then browse around their project directory moving statements and functions into that file by using the bookmark as the destination of a "move"
command.
The second component that makes cursorless bookmarks powerful is the fact that a cursorless target can be much more than just a location in a document. Cursorless targets can contain rich contextual information such as how the target functions within the parse tree of the file to enable smart updating such as adding new items to a list. Cursorless targets could also be stitched together into cross file bookmarks to enable updating multiple files at the same time. Cursorless targets also needn't be restricted to locations in documents at all. See below for a bit more about this type of use case.
"mark"
which bookmarks its target. This goes into the default "mark"
bookmark, which can then be used in a phrase such as "take mark"
"mark <target> as <word>"
and that would create a named bookmark so the user could say "take [mark] <word>"
In this section we discuss various advanced / experimental possible use cases for cursorless bookmarks. See What's next for more about this type of use case.
These bookmarks could actually be used to capture arbitrary targets, literal strings, snippets made on the fly from targets by specifying "holes", etc. This functionality enables much more complex chains because they can extend beyond a single voice command
These "bookmarks" could go into the user's bookmark library to be used again
Could capture recent sequence of commands, or sequence of commands leading to a bookmark, allowing user to turn that into a reusable pipeline that goes into the library as well. Should these pipelines just be a form of bookmark / target as well?
Could be defined via a regex rather than a range, to make them more robust. Would be useful for long-lived marks, marks that are persisted with the repo, and plop.js-like functionality
Cursorless has support for handling delimited sequences, eg argument lists. We should add support for cursorless automatically detecting that a token is in a sequence of whitespace-delimited tokens so that it can do smart things like automatically removing extra spaces the way it does with commas. This functionality will be useful for editing prose
There are a couple commands where the pending change highlights appear in sequence. This slows down the action and makes it so that sometimes the cursorless decorations will move before another command can be executed. We'd like to make these commands show the highlights at the same time. The commands are:
Eg "def show air in split bat". This way you can show something in the other split. This would be especially useful combined with #46 , eg "take green dog in split fine"
Could simplify to "other" or "right" etc
Chuck line behaves more like a clear with an empty line remaining. Is this by design or a bug?
Here's a file that triggers the error. Say "take every funk" when cursor is in private function at the bottom
import * as vscode from "vscode";
import { join } from "path";
import { COLORS } from "./constants";
import { SymbolColor } from "./constants";
export type DecorationMap = {
[k in SymbolColor]?: vscode.TextEditorDecorationType;
};
export interface NamedDecoration {
name: SymbolColor;
decoration: vscode.TextEditorDecorationType;
}
export default class Decorations {
decorations: NamedDecoration[];
decorationMap: DecorationMap;
constructor() {
const iconWidth = "1rem";
const iconPath = join(__dirname, "..", "images", "hat.svg");
this.decorations = COLORS.map((color) => ({
name: color,
decoration: vscode.window.createTextEditorDecorationType({
// borderStyle: "solid",
// borderColor: new vscode.ThemeColor(`cursorless.${color}Border`),
// borderWidth: "2px 0px 0px 0px",
// borderRadius: "4px",
// backgroundColor: new vscode.ThemeColor(`cursorless.${color}Background`),
rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed,
after: {
margin: `-1rem 0 0 -${iconWidth}`,
width: iconWidth,
height: iconWidth,
color: new vscode.ThemeColor(`cursorless.${color}Border`),
contentIconPath: iconPath,
},
}),
}));
this.decorationMap = Object.fromEntries(
this.decorations.map(({ name, decoration }) => [name, decoration])
);
}
private constructWrapperSvg() {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M19 13H5v-2h14v2z"/></svg>`;
return vscode.Uri.parse(`data:image/svg+xml;utf8,${svg}`);
}
}
As mentioned in #24, it might be useful to support type parameters.
I think the simplest place to start for type parameters (eg the identity<Type>
example) would be to just add them to the argumentOrParameter
matcher. Then you could just say "take arg" if your cursor is sitting inside one of them.
I also think it's potentially worth adding them to the type
matcher, but might be a bit tricky because we'd probably only want to catch the type parameter if the mark is in the parameter, not inside eg the function, because in that case we'd prob want the return type
Need to make sure we support the place the type parameter is defined as well as the place that it's instantiated
If we think we'll have a use case for it, we could do something fancier where we can jump from somewhere else to the type parameter of the containing function, but let's see if that ends up being necessary. If we did that, I'd prob call it "type parameter" or "type arg" rather than "type"
If the cursor is anywhere in a token, the user should be able to say "second word" to refer to the second word of the token, without having to select the token first.
We'd like to support a form of range that goes until the beginning of a token rather than at the end. For example, "chuck till trap".
<target>
" is omitted, then it refers to "this", so will wrap cursorSyntax: "call <target>
[on <target>
]"
Examples: "call fine", "call fine on gust past each", etc
In cursorless-vscode and cursorless-talon the color purple is referred to as mauve. Update this to purple make it easier for the documentation.
Needs to be split into multiple files
When calling "fold every element"
on this list, it folds the entire list, but if you call "take every element"
followed by "fold this"
, it works fine
So could say "take next dollar fine" to select the first $
after the given token. Could also say "<ordinal>
<symbol>
", eg "second dollar".
In addition, could support "next line fine", "third line fine", etc, as well as "next funk fine", etc
For convenience, potentially "down <number>
" could be alias for "<ordinal>
line".
Would need to support other direction as well, eg "take last dollar fine", or "take second to last dollar fine", tho the latter is a bit verbose
Use "prior" for opposite of "next"
We should also figure out compact grammar for the following:
"next <symbol>"
eg "next comma"
"next instance <target>"
for selecting next occurrence of a target
<target>
or cursor or able to search from a different target?"next <mark>"
It should always be next instance of given mark's text relative to input. So eg if there is a token "hello"
with a hat over the h
, then "next harp"
will select the next instance of hello
after the cursor
Should support "every"
, "first"
, etc for these as well
Note that for things like :
, ,
, )
, etc, we don't really care about the token that has the hat because it will always just be the one character, so it will behave like we want anyway. For failure modes of this assumption (eg <
and <=
), we can add something like glyph
modifier or something in the future if that becomes a problem
Where plurals make sense (eg "three funks"
), vendor in the following sections of inflection
:
And have csv overrides code generate a list called foo_plural
if you pass in a flag asking for plurals
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.