Skip to content

Putting Bitwise operators in function param does not provide completion #1748

@LewdDeveloper

Description

@LewdDeveloper

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Annotations

Reproduction steps

I have the following code

local FONTFLAG_NONE = 0
local FONTFLAG_ITALIC = 0x001
local FONTFLAG_UNDERLINE = 0x002
local FONTFLAG_STRIKEOUT = 0x004
local FONTFLAG_SYMBOL = 0x008
local FONTFLAG_ANTIALIAS = 0x010
local FONTFLAG_GAUSSIANBLUR = 0x020
local FONTFLAG_ROTARY = 0x040
local FONTFLAG_DROPSHADOW = 0x080
local FONTFLAG_ADDITIVE = 0x100
local FONTFLAG_OUTLINE = 0x200
local FONTFLAG_CUSTOM = 0x400
local FONTFLAG_BITMAP = 0x800

---@alias FontFlags
---| `FONTFLAG_NONE` # 0
---| `FONTFLAG_ITALIC` # 1 (0x001)
---| `FONTFLAG_UNDERLINE` # 2 (0x002)
---| `FONTFLAG_STRIKEOUT` # 4 (0x004)
---| `FONTFLAG_SYMBOL` # 8 (0x008)
---| `FONTFLAG_ANTIALIAS` # 16 (0x010)
---| `FONTFLAG_GAUSSIANBLUR` # 32 (0x020)
---| `FONTFLAG_ROTARY` # 64 (0x040)
---| `FONTFLAG_DROPSHADOW` # 128 (0x080)
---| `FONTFLAG_ADDITIVE` # 256 (0x100)
---| `FONTFLAG_OUTLINE` # 512 (0x200)
---| `FONTFLAG_CUSTOM` # 1024 (0x400)
---| `FONTFLAG_BITMAP` # 2048 (0x800)

---@param name string
---@param height integer
---@param weight integer
---@param flags FontFlags|integer
---@return integer
---@nodiscard
function draw.CreateFont(name, height, weight, flags) end

image
Here, type completion does provide suggestion if param has not been filled

image
After that, i input a | character and open suggestion dialog again, and there's no more FontFlags type

I found a "hack" that works by changing function prototype

---@param name string
---@param height integer
---@param weight integer
---@param ... FontFlags|integer
---@return integer
---@nodiscard
function draw.CreateFont(name, height, weight, ...) end

image

However this hack is not ideal

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions