Re:The 80/24 Rule
by mark-r on Friday November 15, 2019 @11:10AM
(#21545976)
Microsoft Visual Studio has this. You can right-click on a function name and select "Peek Definition", and it will open an inline window with the code for that function.
[ Parent
| on HN ]
Re:The 80/24 Rule
by olejorgenb on Friday November 15, 2019 @11:52AM
(#21546387)
Nice, it actually render the definition inline without placing it in a floating window which is the normal way this feature is implemented: https://docs.microsoft.com/en-us/visualstudio/ide/media/peek...
In gnome-shell-mode [1] we can evaluate arbitrary expression and paste the content (virtually) into the buffer. Since javascript functions evaluate to their source it makes for a poor-mans peek-definition: https://imgur.com/a/7Ot7KFy
It would maybe (sometimes) be nice to even intelligently "macro expanded" the call:
function helper(a, b) {
let c = a + b
return a + c
}
function p(y) {
let x = helper(1+y, 2)
}
-->
function p(y) {
// inlined x = helper(1+y, 2)
let x
{
let c = (1+y) + 2
x = (1+y) + c
}
}
Not the best example, but you get the idea. Expansion can be tricky when the arguments are non-trivial expression. Could fall back to assignment to a variable named after the corresponding parameter.
Re:The 80/24 Rule
by stjohnswarts on Friday November 15, 2019 @12:25PM
(#21546708)
VS Code has this in some of the more developed language plugins and so does eclipse (at least it does for the c++ and python plugins)