LuaLS / LuaLS/lua-language-server
"Expand Selection" doesn't expand to strings or scopes
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
I use VScode's "Expand Selection" command a lot to copy strings around, but when I try to use it on Lua strings, it expands the selection a lot more than just the string I'm on.
## Actual behavior
Suppose my cursor is inside the word example:
> hs.alert(prefix .. " an exam`|`ple string " .. suffix)
1st call to Expand Selection selects the word:
> hs.alert(prefix .. " an `example` string " .. suffix)
2nd call to Expand Selection selects everything between `()` instead of the full string:
> hs.alert(`prefix .. " an example string " .. suffix`)
## Expected behavior
2nd call to Expand Selection should select just the string:
> hs.alert(prefix .. `" an example string "` .. suffix)
In JavaScript, I noticed it even has two steps for the string, the inner part of the string, then the outer:
> alert(prefix + " an `example` string " + suffix)
> alert(prefix + "` an example string `" + suffix)
> alert(prefix + `" an example string "` + suffix)
That would also work!
## Similar scenarios
Scopes are also currently skipped:
> local myFunction = function () ret`|`urn true end
> local myFunction = function () `return` true end <- 1st call selects the word
> local myFunction = `function () return true end` <- expected: 2nd call selects the function scope
> `local myFunction = function () return true end` <- actual: 2nd call selects the line instead
Same for `Object.property`:
> Object.`property` = true
> `Object.property` = true <- expected
> `Object.property = true` <- actual
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Expand Selection implementation and any tests covering selection expansion; the issue does not name specific files or entry points. Reproduce the Lua string, function-scope, and Object.property examples, then add coverage showing that successive expansions select the expected constructs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100