lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

String should be sanitized on hover

Open Aurora2500 opened this issue 1 year ago • 2 comments

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Hover

Expected Behaviour

Consider the following code:

s = "one\ntwo\nthree"

When hovering over it, I'd expect to see the newline characters just as I wrote them in.

Actual Behaviour

Instead, the newlines and tabs would get "expanded", breaking the way the hover looks. lua

Reproduction steps

  1. Create a string variable with newline (\n) or tab characters (\t)
  2. hover over the variable

Additional Notes

No response

Log File

No response

Aurora2500 avatar Dec 06 '23 17:12 Aurora2500

It's just the special characters that need to be double-escaped. Should be quite simple to do. Here is an example from awesome inspect.lua by kikito.

C3pa avatar Dec 22 '23 17:12 C3pa

It's the same for table keys. The following snippet, when hovered gives:

local foo = {
	["some\\path"] = "bar",
}

image

C3pa avatar Dec 30 '23 17:12 C3pa