Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser. Long string doesn't contain leading spaces #3034

Open
TIMONz1535 opened this issue Jan 9, 2025 · 0 comments
Open

Parser. Long string doesn't contain leading spaces #3034

TIMONz1535 opened this issue Jan 9, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@TIMONz1535
Copy link
Contributor

TIMONz1535 commented Jan 9, 2025

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?

Diagnostics/Syntax Checking

Expected Behaviour

local a = "  sss  "
print('"' .. a .. '"')
local a = [[  sss  ]] -- bug with a leading spaces
print('"' .. a .. '"')

local a = [[sss]]
print('"' .. a .. '"')
local a = [[
sss]]
print('"' .. a .. '"')
local a = [[ 
sss]] -- bug with a leading space
print('"' .. a .. '"')

local a = [[sss
]]
print('"' .. a .. '"')
local a = [[
sss
]]
print('"' .. a .. '"')
local a = [[ 
sss
]] -- bug with a leading space
print('"' .. a .. '"')

Parser should produce strings according to Lua rules - in a long string only the first line break is removed, but if it is the first

"  sss  "
"  sss  "
"sss"
"sss"
" 
sss"
"sss
"
"sss
"
" 
sss
"

Actual Behaviour

The leading spaces were skipped, presumably due to the fact that these are not tokens. Or I don't know

local function resolveLongString(finishMark)
skipNL()

local function skipNL()
local token = Tokens[Index + 1]
if NLMap[token] then
if Index >= 2 and not NLMap[Tokens[Index - 1]] then
LastTokenFinish = getPosition(Tokens[Index - 2] + #Tokens[Index - 1] - 1, 'right')
end
Line = Line + 1
LineOffset = Tokens[Index] + #token
Index = Index + 2
State.lines[Line] = LineOffset
return true
end
return false
end

изображение

Reproduction steps

  1. Try to parse long string [[ sss ]]
  2. Now its [[sss ]]

Additional Notes

This also breaks the colorization in addition to #3032, most likely because it breaks the start/finish positions #3028

--[===[@param a string?ComMMul]===]
local function new(a) end

--[===[    @param a string?ComMMS1]===]
local function new(a) end

{914609FD-8D0E-4A1C-9AB8-9915CBB28D91}

Log File

No response

@CppCXY CppCXY added the bug Something isn't working label Jan 9, 2025
TIMONz1535 added a commit to TIMONz1535/lua-language-server that referenced this issue Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants