combobulate
combobulate copied to clipboard
How to select anonymous Javascript function with its variable
How can I select this entire declaration?
const add = (a, b) => {
return a + b;
}
combolute-mark-defn
will select the anonymous function declaration but won't include const add =
. That is 100% correct as it is not part of the function. However conceptually in JS we often think of the above as being equivalent to this:
function add(a, b) {
return a + b;
}
So it'd be nice if, optionally, combobulate could select both uniformly.
Unfortunately combobulate's navigation commands mark by node type, and there is no distinct node types for arrow functions bound to a variable declarator with an optional scoping declaration.
The only way to resolve this is to check the parents of the nodes, which would require changing the list structure combobulate currently uses to one that can scan the parents also. That might happen in the future, but it's sadly not on the roadmap right now.
Workaround is to tap M-h
after C-M-h
to use expand region.
Workaround is to tap M-h after C-M-h to use expand region.
Discovered that it that works - thanks!