You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
only the i of the wrong type (i32) is highlighted rather than the full type
I'm finding this behavior is the same for all diagnostic responses i.e. any issue is apportioned to only one character of the offending token.
Expected Behavior
I expected the entire i32 to be underlined but only the first character is.
My assumption would be that the end in the diagnostics message should maybe be {"line":3,"character":37} but I could be wrong.
Relevant log output
debug (message): received: {"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///Users/ooooo/Documents/code/zig-audio/zed-syntax-highlighting-test/src/test.zig"},"text":"const std = @import(\"std\");\n\ntest \"test\" {\n const x: i16 = std.math.maxInt(i24);\n _ = x;\n}\n"}}
debug (server): Took 0ms to process notification-textDocument/didSave on Thread 1781099
info ( diag ): Running build-on-save: file:///Users/ooooo/Documents/code/zig-audio/zed-syntax-highlighting-test/build.zig (check)
debug (message): sent: {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/ooooo/Documents/code/zig-audio/zed-syntax-highlighting-test/src/test.zig","diagnostics":[{"range":{"start":{"line":3,"character":35},"end":{"line":3,"character":35}},"severity":1,"code":"zig_build","source":"zls","message":"type 'i16' cannot represent integer value '8388607'","relatedInformation":[]}]}}
Further Digging
From looking through the zls code the culprit appears to be here.
As mentioned in the comment it would appear that (given we're interpreting the zig build check output) a fix would be
read the src file
tokenize using std.zig.Tokenizer
find the token that corresponds to the line/character
set range to the range of the token
I'm happy to take a look at getting a PR together if this would work for folk but wanted to check before hand.
The text was updated successfully, but these errors were encountered:
I plan to do some internal changes to how ZLS aquires build-on-save diagnostics from ZLS (related: #2006, #2001). Zig generates diagnostics as std.zig.ErrorBundle which contains the necessary information to figure out the end position of the diagnostic without having to read the source file itself.
Zig Version
0.14.0-dev.2034+56996a280
ZLS Version
0.14.0-dev.179+5acc066
Client / Code Editor / Extensions
Zed 0.158.2
Steps to Reproduce and Observed Behavior
Can recreate with this repo.
test.zig
i32
to another wrong type i.e.i24
i
of the wrong type (i32
) is highlighted rather than the full typeI'm finding this behavior is the same for all diagnostic responses i.e. any issue is apportioned to only one character of the offending token.
Expected Behavior
I expected the entire
i32
to be underlined but only the first character is.My assumption would be that the
end
in the diagnostics message should maybe be{"line":3,"character":37}
but I could be wrong.Relevant log output
Further Digging
From looking through the
zls
code the culprit appears to be here.As mentioned in the comment it would appear that (given we're interpreting the
zig build check
output) a fix would bestd.zig.Tokenizer
I'm happy to take a look at getting a PR together if this would work for folk but wanted to check before hand.
The text was updated successfully, but these errors were encountered: