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
I am expecting it to not warn me about a casting issue when there is none.
Actual Behaviour
I am getting a casting warning on a variable that should not be an issue.
[{
"resource": "/D:/git/ThreshCopy/src/scripts/ThreshCopy/Copy_Collapsed.lua",
"owner": "_generated_diagnostic_collection_name_#0",
"code": "cast-local-type",
"severity": 4,
"message": "This variable is defined as type `string`. Cannot convert its type to `string|nil`.\n- `nil` cannot match `string`\n- Type `nil` cannot match `string`",
"source": "Lua Diagnostics.",
"startLineNumber": 56,
"startColumn": 3,
"endLineNumber": 56,
"endColumn": 18
}]
Reproduction steps
While it is true that getSelection() can return nil, I do accommodate for it with my or statement
parsed=parsed.. (getSelection(window) or"")
This is where it is squiggling
Additional Notes
Here is everything that is relevant that should help.
localThreshCopy= {}
functionThreshCopy:trim(s)
returns:match("^%s*(.-)%s*$")
endfunctionThreshCopy:getSelectedText(window, startCol, startRow, endCol, endRow)
-- Check whether there's an actual selectionifstartCol==endColandstartRow==endRowthenreturn"" endlocalparsed=""-- Loop through each symbol within the rangeforlineNum=startRow, endRowdolocalcStart=lineNum==startRowandstartColor0moveCursor(window, cStart, lineNum)
localcEnd=lineNum==endRowandendColor#getCurrentLine() -1selectSection(window, cStart, cEnd-cStart+1)
parsed=parsed.. (getSelection(window) or"")
iflineNum~=endRowthenparsed=parsed.."\n" endendreturnparsedendThreshCopy.handler=function(event, menu, ...)
localtext=ThreshCopy:getSelectedText(...)
-- Split the text into lines, trim each line, and handle blank lines separatelylocallines= {}
forlineintext:gmatch("([^\n]*)\n?") doifline=="" thentable.insert(lines, "")
elsetable.insert(lines, ThreshCopy:trim(line))
endend-- Join lines, preserving empty lines as blank lineslocalwithoutNewLines=""localpreviousLineEmpty=falsefor_, lineinipairs(lines) doifline=="" thenwithoutNewLines=withoutNewLines.."\n\n"previousLineEmpty=trueelseif#withoutNewLines>0andnotpreviousLineEmptythenwithoutNewLines=withoutNewLines..""endwithoutNewLines=withoutNewLines..linepreviousLineEmpty=falseendend-- Remove any trailing newlineswithoutNewLines=withoutNewLines:gsub("%s*\n*$", "")
setClipboardText(withoutNewLines)
end
Log File
No response
The text was updated successfully, but these errors were encountered:
Could you @gesslar perhaps please provide a minimized example?
I believe there is a larger chance to actually resolve this issue if reducing the code only to the few lines to illustrate the problem you are having. With half-a-thousand open tickets, monotonously increasing, one wonders what the purpose of filing an obviously non-actionable ticket on this project is.
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?
Type Checking
Expected Behaviour
I am expecting it to not warn me about a casting issue when there is none.
Actual Behaviour
I am getting a casting warning on a variable that should not be an issue.
Reproduction steps
While it is true that
getSelection()
can returnnil
, I do accommodate for it with my or statementThis is where it is squiggling
Additional Notes
Here is everything that is relevant that should help.
Log File
No response
The text was updated successfully, but these errors were encountered: