xsburg / vscode-javascript-booster

Sprinkle extra refactorings, code actions and commands over your JavaScript! 🍩 TypeScript and Flow are first class citizens as well!
https://marketplace.visualstudio.com/items?itemName=sburg.vscode-javascript-booster
159 stars 13 forks source link

Don't use activeTextEditor inside provide-function #5

Closed jrieken closed 6 years ago

jrieken commented 6 years ago

We have found that this extension uses activeTextEditor inside the provideCodeActions-function, see https://github.com/xsburg/vscode-javascript-booster/blob/bb541fef09d85942bb8be5d52ca8fd94aab0f572/src/CodeModCodeActionProvider.ts#L18

While the assumption is often true it's not always the active editor in which code actions are being requested for. Think of api-commands or the run-code-action-on-save feature that are going to ship with 1.23.

Please join our discussion here https://github.com/Microsoft/vscode/issues/49024.

Thanks & Happy Coding

xsburg commented 6 years ago

Thanks for the heads up, I got a bit confused whether the range parameter provides document.selection already (it wasn't the case a couple of versions ago). I'll check and fix the code once I confirm that (or when a new version of VSCode with the discussed changes arrives).

jrieken commented 6 years ago

Yeah, it's almost always the selection but something something different...

lostintangent commented 6 years ago

@xsburg Hey! Now that Microsoft/vscode#49024 is deployed in Stable, did you have any plans to refactor your code actions to use it? This change would actually benefit VS Live Share, since the use of activeEditor prevents a "guest" in a collaboration session from running a code action within a file that the "host" isn't also actively editing. I'd love to get JS Booster working great with Live Share!

xsburg commented 6 years ago

@lostintangent Hi! I was delaying the fix so that everybody gets the updated version of VSCode. Now I think it's time to release the refactoring on my part. I've just pushed the changes and will probably release an update in a couple of days.

I have a related question though, will the command triggered by a code action have access to activeEditor when a "guest" is editing a file which is not being edited by the "host"? I assume it has but based on your description I have a few doubts about how VS Live Share handles it.

xsburg commented 6 years ago

The issue is addressed in v0.10.0.