Skip to content

Fix correctly display enums for function overload arguments #2840

New issue

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

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

Already on GitHub? Sign in to your account

Merged

Conversation

NeOzay
Copy link
Contributor

@NeOzay NeOzay commented Sep 6, 2024

to achieve this bug requires function overloading and multiple variable assignment.

---@return string, number
---@overload fun(s: "test", a?:number):name:"name", string
function test() end

local name, aString = test("|") --- can see "test" and "name", only "test" is expected

using the debugger I go back to the findNearestSource function which does not see the correct source.
guide.eachSourceContain only returns the same source once, so you need to check if it is closer.

local function findNearestSource(state, position)
    ---@type parser.object
    local source
    guide.eachSourceContain(state.ast, position, function (src)
        if not source or source.start <= src.start then
            source = src
        end
    end)
    return source
end

@NeOzay NeOzay changed the title Fix auto completion of arguments when overloading functions Fix correctly display enums for function overload arguments Sep 6, 2024
@sumneko sumneko merged commit a126e9c into LuaLS:master Sep 9, 2024
11 checks passed
@sumneko
Copy link
Collaborator

sumneko commented Sep 9, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants