el-falso / gdlinter

This plugin runs `gdlint` on save to automatically lint your GD Script as you code.
https://godotengine.org/asset-library/asset/2520
MIT License
15 stars 5 forks source link

Dock : Line number is truncated ("131" becomes "13") #13

Open axel37 opened 3 months ago

axel37 commented 3 months ago

Hi !

I've just installed the project and stumbled upon an issue : it seems that, in long files, the line number is shown incorrectly.

In-engine screenshot :

Plugin reports an error at line 13, while the error is at line 131.

Manually running gdlint in terminal :

The original terminal program correctly reports an error at line 131

As we can see, gdlint reports the correct line number (131), while the plugin truncates it to the first 2 characters (13).


Godot : v4.2.2.stable.official [15073afe3] GDLint Plugin : 2.0.2, installed in-engine through AssetLib gdlint : 4.2.2, installed with pip3

Thanks for the plugin ! :tada:

axel37 commented 3 months ago

After a little digging, it looks to be a display issue, the underlying data seems to be parsed correctly.

(I only spent 15 minutes on this, so you might not want to take my word for it :stuck_out_tongue_closed_eyes: )


In Dock.gd, at create_item(), the line number is still correct :

func create_item(line: int, name: String) -> void:
        #>> Start ninja debugging <<#
    print("GDLint : got error at line :")
    print(line)
        #>> End ninja debugging <<#

    var regex = RegEx.new()
    regex.compile("(?<=\\()[^\\)]+")
    var result := regex.search_all(name)
    var error_type := result[-1].strings[0]
    if _ignore.get(str_dash_to_underscore(error_type)):
        num_ignored_problems += 1
        return

    var item := tree.create_item()
    item.set_text(0, str(line))
    item.set_text(1, name)
    item.set_metadata(0, line)

    if error_descriptions.error.has(error_type):
        item.set_tooltip_text(1, error_descriptions.error[error_type])
    num_problems += 1

Outputs :

GDLint : got error at line :
131
el-falso commented 3 months ago

Thank you for the bug report, that's interesting that Godot doesn't respect the minimum size I set the column to.