-
-
Notifications
You must be signed in to change notification settings - Fork 958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Best replacement for vscode.window.activeTextEditor
?
#933
Comments
Use |
@chemzqm I might be using it wrong… but I get My code: const doc = await workspace.document;
const range = await workspace.getSelectedRange('v', doc.textDocument); |
You should pass result of visualmode function as mode argument |
Where can I find that function? |
I found this: const editMode = (await workspace.nvim.mode).mode but it doesn’t seem to work right: const doc = await workspace.document;
const editMode = (await workspace.nvim.mode).mode
const range = await workspace.getSelectedRange(editMode, doc.textDocument);
// OUTPUT: [coc.nvim] Mode 'n' is not supported This is odd because I was in visual mode when I ran my command that triggers this code (F8 which runs an editor command whos code I’m looking to simplify 😅) |
Checkout |
The command can take argumenst, you can pass |
Ok so that gives me this at the bottom: Then I hit ENTER and get:
What I ran:
My code: let doEval = async function(mode: string) {
let document = await workspace.document
if (!document || document.filetype !== 'ps1') {
return
}
const doc = await workspace.document;
const range = await workspace.getSelectedRange(mode, doc.textDocument);
client.sendRequest(EvaluateRequestType, {
expression: content,
});
await proc.scrollToBottom()
}
let cmdEvalSelection = commands.registerCommand("powershell.evaluateSelection", async (mode) => doEval(mode)); |
Don't know how you invoke action list, it's better to build coc.nvim from source code so you can debug it by Chrome, instead of ask me https://github.com/neoclide/coc.nvim/wiki/Debug-coc.nvim |
Something that’s done in the PowerShell extension is:
So that we can get the selected range or the range of the full line if nothing is highlighted. We take this selection and run it in the terminal below.
Is there any good replacement API for this in coc?
The text was updated successfully, but these errors were encountered: