Closed zardoy closed 1 year ago
Yeah, that sounds possible. More over it can probably "reuse" the same null
template which does different thing because only one of them should be available in particular context. Original null
template won't show up inside an if
statement for instance.
Original null template won't show up inside an if statement for instance
I don't really remember how overriding works, but what is user decide to override original null
template (like I did), will this special null
template still be showing up? But what if someone want to disable it (to not be annoyed in binary expressions). I hope there is universal solution for this. IMO make templates more contextual overall should be main direction here!
I don't really remember how overriding works, but what is user decide to override original
null
template (like I did), will this specialnull
template still be showing up?
Yes because the same template name can appear many times as long as canUse
returns true:
https://github.com/ipatalas/vscode-postfix-ts/blob/b83e0d288b296c514c10d23ea699fae01abb522b/src/postfixCompletionProvider.ts#L49-L58
But what if someone want to disable it (to not be annoyed in binary expressions). I hope there is universal solution for this. IMO make templates more contextual overall should be main direction here!
Yes, in this case it should be either one of them but not both at the same time unless there is a context when they both make sense but I don't see any now.
Implemented in https://github.com/ipatalas/vscode-postfix-ts/commit/3299b786704c4888086fa1b9548d77453132b52f - I've added that not only to if
statements but also to return
and variable assignment so you can do pretty much the same there:
return x.null // -> return x === null
const a = b.null // -> const a = b === null
I think I forgot to close this one :)
What do you think of adding these postfixes inside
if
? For example:From my POV its quite common to compare something with
undefined
in existing if conditions