vscode-postfix-ts icon indicating copy to clipboard operation
vscode-postfix-ts copied to clipboard

Add a way to invert `if`/`while` condition

Open zardoy opened this issue 3 years ago • 1 comments
trafficstars

Example: if (a && a && b{not}) it would invert last identifier instead and it seems there is no way to invert whole condition in this case.

As a workaround I'm writing thing like a > 0.not at the end to invert an if condition.

WebStorm in example above would suggest multiple variants, however introducing this behavior would be too annoying for existing users, instead I think it can support this:

if (a && a && b).not {
    ...
}

zardoy avatar Sep 22 '22 13:09 zardoy

This was a result of bugfix for #67. Apparently the fix wasn't perfect. I've redone the fix to apply it only where it makes sense instead of globally and now it's back to old behavior:

image

image

That's quite a big and potentially breaking change: https://github.com/ipatalas/vscode-postfix-ts/commit/a126e74e3f201507eef55108fd91cbb74b396a86 Feel free to test it, maybe you can figure out an edge case I did not find :)

ipatalas avatar Sep 23 '22 12:09 ipatalas

Had a chance to test that? I guess this should no longer be a problem.

ipatalas avatar Oct 28 '22 08:10 ipatalas

That's quite a big and potentially breaking change: https://github.com/ipatalas/vscode-postfix-ts/commit/a126e74e3f201507eef55108fd91cbb74b396a86

I thought this commit closed it

zardoy avatar Oct 28 '22 13:10 zardoy