Fork me on GitHub
#calva
<
2021-01-19
>
clyfe11:01:38

How do I get the updated document after running a command in vscode?

const activeTextEditor = vscode.window.activeTextEditor;
const document = activeTextEditor.document;
console.log("before: ", document.lineAt(line).text.length);
await executeCommand("calva-fmt.formatCurrentForm");
console.log("after: ", document.lineAt(line).text.length);
Before and after are the same all the time. I don't get the new stuff. PS: not sure where's a good place to ask this. https://vscode-dev-community.slack.com is silent.

pez11:01:51

This is a fine place to ask (even if I get a lot of help in that slack team, in the #vscode-extension-dev channel). I’m not sure what’s going on in your code there, but maybe you get the new document with the promise resolution? So what happens if instead of await you slap a .then(doc => … on the executeCommand call?

pez11:01:13

I don’t know if you know, but anyway, an extension can expose an API to other extensions. So if there are functions/methods/info you want access to we can consider exposing them. It will of course need to be with great care we expose such an API, but the option is there. You can experiment with it at least by building your own Calva VSIX (I’m not sure how you would do it from the dev extension host when there are two extensions involved, or even if it’s possible).

clyfe11:01:51

.then same story; something immutable involved with that document be nice having paredit functions exposed by extension, yes; I'll do dev thing see what gives thank you!

pez12:01:32

Probably the promise resolves earlier than what you need.

🎯 3
clyfe09:01:37

I probably missed the async; seems it works now.

clyfe15:01:48

https://github.com/clyfe/vscode-calva-setup/blob/master/powertools/killSpaceBackward.js killSpaceBackward aka "the new backspace", takes your sexps to the finish-line directly, no more delete space by space (but we need to expose fmt fns in the extension api first - pr incoming; also: some refactoring required there)

pez15:01:53

Just to manage expectations. We will have to think very carefully before exposing any API from Calva. PR welcome, but it will take some serious pondering on our side.

👍 3
levitanong17:01:22

Hi all, is there a way to interrupt an evaluation?

bringe17:01:46

That's a Calva command for it you can find in the command palette

bringe17:01:53

Search "interrupt"

levitanong17:01:43

I tried it, but it doesn't seem to stop the deluge of stuff being written onto the output buffer 😆

bringe17:01:40

Hmm, I think that command may not solve all situations like that. Feel free to create an issue for your situation with repro steps

bringe17:01:52

Can't guarantee we can fix, but worth a look

levitanong17:01:36

Thanks! I'll see first if I can find a workaround other than quitting vscode 😆

bringe17:01:11

If it's not completely frozen you can try killing the repl at the terminal. If that doesn't work you can try the "Developer: Reload Window" command to make restarting it easier at least

levitanong18:01:21

Got it, thanks!

pez20:01:10

So, the output window queues up prints and because reasons prints them quite slowly. So it can keep printing for quite long after you have interrupted a command… Maybe there is something we could do about it….

levitanong04:01:09

I imagine the printing is throttled so that it doesn't interfere with the responsiveness of the rest of the app. If this were implemented with core async (it probably isn't 😆 ) simply closing the channel should cancel the rest of the queue.

pez07:01:40

This is TypeScript and promises. 😃 Would be nice to just close a channel. Maybe we can achieve that somehow…

bringe18:01:50

The printing isn't intentionally throttled, it's just that the applyEdit function of the vs code api is async and a bit slow, and if we don't ensure one prints before the previous, we get issues.

bringe18:01:06

But anyway, I think we can clear the queue pretty easily, it's just an array

levitanong05:01:04

It seems you've put in quite a bit of hammock time on this! Would I be correct in my understanding that repro steps are no longer necessary?

bringe17:01:50

If you wouldn't mind creating an issue about the printing after interruption, that would be great so we can track it for later, and remember who brought it up, in case we can't repro or would like some info/help. simple_smile

bringe17:01:02

Can't say I'll get to it soon though

levitanong04:01:17

No problem! I'm in no hurry. I'll make the issue, and try to summarize what you've said here.

levitanong04:01:39

Here it is! https://github.com/BetterThanTomorrow/calva/issues/978 Please correct me if I made a mistake anywhere

clyfe20:01:06

not sure what I broke but I can't send anything to the calva repl; tried all the tricks, downgrade, delete caches, restart...

clyfe20:01:04

Is there a log of sorts somewhere to look at?

pez20:01:45

What do you mean by “send to the calva repl”?

pez20:01:36

See if the vscode dev console has any clues. (I think you access it from the Help menu).

clyfe20:01:22

> console.ts:137 [Extension Host] Unhandled error: e.trim is not a function That pops when I type enter in the repl after a form

clyfe20:01:10

> [Extension Host]% [] and that when I type a character in the repl

clyfe20:01:02

> console.ts:137 [Extension Host] (node:11997) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. Can't tell if it's calva where this originates

pez20:01:39

That Buffer warning is a vscode thing, I think.

pez20:01:24

The other ones I do not think stem from Calva. I don’t get them, at least.

clyfe20:01:32

Buffer stuff is from Calva, by elimination. Disable calva -> no Buffer err Enable calva -> Buffer err

pez21:01:27

It has been there since forever anyway. 😃 I probably have some other extension that causes it, because disabling Calva does not get rid of it for me. In any case it is probably not what is causing you problems.

clyfe21:01:08

Works now, dunno why, it's the ~27th time I try...

pez21:01:15

Super weird. And worrying….

clyfe21:01:21

Calva works when I disable ego-digital.vscode-powertools extension. These 2 don't get along - they were this morning.

pez21:01:04

We did release a new Calva today, see if that changed anything?

clyfe21:01:37

same on 2.0.151; very strange; I'll try to replace powertools with something; most likely make my own extension calva-extras instead these scripts.

pez21:01:34

Often called Calvados Extra, so just dropping the trailing s would fit the metafor.

bringe20:01:44

Calva version 2.0.152 is released with the following changes 🎉 calva • Fix: https://github.com/BetterThanTomorrow/calva/issues/959https://github.com/BetterThanTomorrow/calva/issues/931