Skip to content

插件添加comment导致样式出问题 #3284

@ushen-pyj

Description

@ushen-pyj

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?

Plugins

Expected Behaviour

Image

这是正常的表现
当我在插件写这样的代码的时候

function OnTransformAst(uri, ast)
    guide.eachSourceType(ast, "call", function (source)
        local node = source.node
        if not guide.isGet(node) then
            return
        end
        if not guide.isGlobal(node) then
            return
        end
        if guide.getKeyName(node) ~= 'Class' then
            return
        end
        local wants = {
            ['local'] = true,
            ['setglobal'] = true
        }
        local classnameNode = guide.getParentTypes(source, wants)
        if not classnameNode then
            return
        end
        local classname = guide.getKeyName(classnameNode)
        if classname then
            local group = {}
            helper.addClassDoc(ast, classnameNode, classname, group)
            helper.addDoc(ast, classnameNode, "field", "a string", group)
            helper.addDoc(ast, classnameNode, "field", "b string", group)
            helper.addDoc(ast, classnameNode, "field", "c string", group)
        end
    end)
end

样式会变成这样

Image

Actual Behaviour

Image

另外,如果这个时候对着变量按F2重命名,会出现field的名称,

或者按ctrl对着某个地方跳转,也可以跳转到定义

也就是虚拟的comment会被选中

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions