Skip to content

"Expand Selection" doesn't expand to strings or scopes #3455

Description

@gab-john

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions