LuaLS / LuaLS/lua-language-server

Putting Bitwise operators in function param does not provide completion

未关闭
#1,748 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement
主要语言
Lua
星标
4.4k
派生
442
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

在 Visual Studio Code 扩展中使用提供的 Lua 注解和函数原型重现该问题。首先比较在 flags 参数中输入 | 前后的补全结果;当位运算符之后仍能提供 FontFlags 建议时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
lua, vscode
领域
devtools
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。