Closed CarlosLeyvaAyala closed 3 years ago
Hi @CarlosLeyvaAyala ,
Could you please update the outline picture with the whole line content, so I could better understand how VS Code/Lua Language Server describes a callback
function?
Thanks in advance
Like this?
BTW, I also found some kinda real code that use more inline anonymous functions that get detected. I hope this also helps :)
I guess so 😄
Only those described as <Anonymous>
, with a -> function
detail are Callback Inline, right?
There's also a named inline function called me2
in the second screen I took (typo), but correctly named meh2
in my first message. It belongs to meh
:
That function is the equivalent to having a void => void
signature, or something; that's why it's so easy to overlook.
But this one is not a callback
right? It seems just an inline/anonymous declaration.
I never worked with Lua, so I can't say for sure. I'm just comparing to other languages I play with.
That's right. It's not a callback.
In Lua all functions that can be declared both as a variable and as a function statement:
Those functions can only be used inside the function where it were defined, as expected.
Look at how this is actually complaining that inlineVoid
hasn't been defined:
If I take out that problematic line and run the code above, I get this:
Printed 5
Anon printed 5
Printed 5
Anon printed 15
Printed 5
Anon printed 25
When you evaluate the resulting anonymous function:
Result print 5
I could have declared all those inlines in a single line like I did with addAnon
, by the way.
Sadly (fortunately to you, so you don't have to take so many cases into account? xD), in vanilla Lua there's nothing like lambda notation, "fat arrows", or whatever, to make one liners more succint.
If you want to declare a one line function, it ought to have the whole body declaration, like this:
function OneLiner() end
OneLinerAnon = function() end
That's great!
BTW, which Lua extension are you using, and how it does identify Lua files? Simply lua
?
I need to know this, to properly identify the files and to filter the symbols.
Thank you
I use Lua.
I'm not sure how it recognizes files, other than the *.lua
extension.
As far as I know, that's the only extension for Lua files and searching for other extensions gave me nothing.
BTW, I'm the one that should thank you for your patience.
It's not the file extension, but how the extension declares the language Id (lua
). Looking at extension's source I'm able to find.
I don't have a setup to try out, but I hope the details you provided (and my interpretation) will be enough. It should be available next month, right after VSCode release.
BTW, I'm the one that should thank you for your patience.
Thank you too for providing the details. Without that, the feature wouldn't be released (at least, not by me) 😬
Thank you
Thank you so much! If more info is needed, I hope I can provide it. Don't hesitate to ask me.
Let's hope it works out of the box, otherwise will be you asking me, for a fix 😆
It should be available next week.
Stay tuned
I tried this option and unfortunately, it seems it doesn't do the trick for me:
Purple lines are from Separators plugin v2.3.0. The setting is set:
"separators.functions.ignoreCallbackInline": true,
Happy to help with debugging.
Hi @ypnos ,
As described in the comment above (https://github.com/alefragnani/vscode-separators/issues/50#issuecomment-903334676) these are not considered callbacks.
These ones are just inline/anonymous functions.
Hope this helps
Ok so I just misunderstood, I thought "ignoreCallbackInline" means "ignore callback and inline". I understand it better now.
Here is example code to confirm that it works:
No problem. If you misunderstood, it means the setting is not so clear, and the documentation needs improvement.
Anyway, if you miss the possibility to ignore inline
/anonymous
functions, this could be accomplished with a new setting. Feel free to open a new issue for that, providing the details to identify/differentiate inline
/ anonymous
functions.
Hope this helps
BTW, thank you for the confirmation the current setting is working 👍
Hi. I'd like to ask if it is possible to add support for Lua for the
functions.ignoreCallbackInline
setting.Here are some sample functions with inlines:
And their respective structure in the outline: