brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

Toggle Block Comment doesn't work with multiple cursors in one comment #12621

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by njx Monday Apr 14, 2014 at 23:29 GMT Originally opened as https://github.com/adobe/brackets/issues/7510


  1. Open a JS file with a multiline block comment
  2. Create multiple cursors inside the block comment
  3. Edit > Toggle Block Comment

Result: Nothing happens. This is because we iterate over each selection independently, but both selections would try to generate the same edit (remove the outer block comment), and those overlapping edits get rejected by doMultipleEdits().

core-ai-bot commented 3 years ago

Comment by njx Monday Apr 14, 2014 at 23:32 GMT


There are quite likely other issues like this in the commenting code, because in general the code reaches outside each individual selection in order to figure out what to do. There are a few different approaches I could imagine taking to fix this:

The latter is probably easier and straightforward, but it wouldn't catch cases where, for example, the comment code wants to do two different things that overlap for nearby selections. I would think that that latter case should only occur for pathological combinations of selections where it's not obvious what the user wants anyway.

core-ai-bot commented 3 years ago

Comment by njx Monday Apr 21, 2014 at 18:10 GMT


Reviewed. Low pri to me.

core-ai-bot commented 3 years ago

Comment by peterflynn Monday Apr 21, 2014 at 18:22 GMT


@njx What about inflating the selections to cover the entire comment that they'll affect, and then coalescing selections that are overlapping? I assume the selection manipulation APIs would give us the coalescing for free in that case. (We'd want to do this on a clone of the original selections though I guess, since we want to roughly preserve the user's original selection state after the edits).

core-ai-bot commented 3 years ago

Comment by njx Thursday Jul 10, 2014 at 16:16 GMT


Yup, something like that might work too, but I don't remember the commenting code well enough to know if that's easier than one of the other options.