Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(completion): truncate arguments for callSnippet #1014

Merged
merged 3 commits into from
Apr 4, 2022

Conversation

kevinhwang91
Copy link
Contributor

The callSnippet always expands all the optional arguments and variable
argument that is annoying.
To truncate optional arguments and variable arguments help users more
frequently use callSnippet. We already have the label and signature to get
the total arguments.

This behavior is like tsserver.

The callSnippet always expands all the optional arguments and variable
argument that is annoying.
To truncate optional arguments and variable arguments help users more
frequently use `callSnippet`. We already have the label and signature to get
the total arguments.

This behavior is like tsserver.
@kevinhwang91
Copy link
Contributor Author

Found a bug about optional arguments is not continuous, needs to be fixed.

If the arguments are all optional or variable until the end, we can
truncate them directly.
@sumneko
Copy link
Collaborator

sumneko commented Apr 3, 2022

I don't quite understand your requirements. Can you add some tests to make me understand your changes?

@kevinhwang91
Copy link
Contributor Author

kevinhwang91 commented Apr 3, 2022

I have tested under the below code:

--- Test
---@param a number
---@param b? number
---@param c? number
---@vararg number
local function foo(a, b, c, ...) end

-- type `foo`

You can change the arguments optional status to quickly check out the logic that is like tsserver.

@kevinhwang91
Copy link
Contributor Author

OK, I need time to explore the test framework. BTW, it's too late and it's time to sleep now. o_o

@sumneko
Copy link
Collaborator

sumneko commented Apr 3, 2022

OK, I need time to explore the test framework. BTW, it's too late and it's time to sleep now. o_o

Thank you, have a nice dream!

@kevinhwang91
Copy link
Contributor Author

Please review the code and share your idea. :)

@sumneko
Copy link
Collaborator

sumneko commented Apr 4, 2022

It make sense, thank you!

@sumneko sumneko merged commit 3905068 into LuaLS:master Apr 4, 2022
@kevinhwang91 kevinhwang91 deleted the truncate-opt-and-variable branch April 4, 2022 07:46
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants