vscode-expand-selection-to-scope icon indicating copy to clipboard operation
vscode-expand-selection-to-scope copied to clipboard

Shrink selection planned?

Open Chippi opened this issue 7 years ago • 6 comments

I can't really work with this plugin without this important feature

Chippi avatar Apr 21 '17 07:04 Chippi

You can undo last operation (CTRL+Z) to shrink the selection back.

Anyway implementing this feature as you might have had in mind is rather difficult or impossible. Imagine you have these two inner scopes, expand selection to the outer one, then shrink back. Which one of the two inner scopes will be selected? The one true answer might have been both, then it's feasible to implement, but it may not be practical.

var outerScope = {
  fn: () => {
    return {
      a: true,
      b: "first inner scope"
    }
  },
  fn2: () => {
    return {
      a: "second inner scope",
      b: "expand selection from here"
    }
  }
}

ackvf avatar Apr 21 '17 08:04 ackvf

You could save all selection expand positions in a history array. Then you can always track your way back.

Chippi avatar Apr 21 '17 09:04 Chippi

So you didn't mean a general shrinking ability, you should have been more clear. Anyway, if you want to undo an expand selection, you can use aforementioned CTRL+Z.

ackvf avatar Apr 21 '17 09:04 ackvf

My first thought was a general shrinking ability. But after your answer, I changed my mind to a history tracking solution. Of course you can use CTRL+Z. But it feels like an anti-pattern / quick hack.

Chippi avatar Apr 21 '17 09:04 Chippi

Agree. I have reported it as an issue yesterday. Selection tracking history sounds reasonable and is a good feature request.

ackvf avatar Apr 21 '17 09:04 ackvf

Alt+←/ is a cursor position history. It would be nice to undo/redo expansion on these keys as well.

ackvf avatar Apr 25 '17 08:04 ackvf