brackets-archive / bracketsIssues

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

[CLOSED] Pasting with multiple selections #6517

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by wnr Monday Mar 17, 2014 at 09:06 GMT Originally opened as https://github.com/adobe/brackets/issues/7211


  1. Select two words (applies to anything, not only words). Lets say the first selected words is "foo" and the second one is "bar"
  2. Hit Ctrl-C
  3. Press right arrow once (which will set the two cursors to the end of the previously selected words).
  4. Hit Ctr-V
  5. Now the words have been inserted and we now got "foofoo" "barbar" as expected.

The problem:

  1. Place a cursor on a line. Lets say "foo\n"
  2. Hit Ctrl-L to select the whole line.
  3. Make another word selection on another line. Lets say "bar" Now one line should be selected and one word on another line.
  4. Hit Ctrl-C
  5. Press right arrow once (which will set the two cursors at the end of the previously selected ranges).
  6. Hit Ctrl-V V. Now a combination of the two words has been inserted at both cursors (which is not the same behaviour as when only words are selected). So now instead of having "foo\nfoo\n" and "barbar" we have "foo\nfoo\n\nbar" and "barfoo\n\nbar".

EDIT: Below is just a personal opinion and is not really the bug. Since Sublime doesn't behave as described below, I understand that we might skip my suggestion below. So the paragraph below can be skipped.

Also, I think that the copied selections never should be merged. Right now, if you have two selections and copy-paste, it would be the same behaviour as if i did each copy paste separately (which is cool). However, if doing copy with two selections and then one of the cursors is removed (so only one is left) then I think that a paste should result in only the previously primary selection should be pasted (not the merge of the two previously selections).

core-ai-bot commented 3 years ago

Comment by njx Monday Mar 17, 2014 at 10:22 GMT


I think this is because CM assumes that each copied selection is a single line, so if the number of copied lines doesn't match the number of selections, it pastes everything. I'm not sure if there's some more clever way it could store the information about multiple selections on the clipboard, since there really isn't any way for JS to put anything special on the clipboard - the only thing you can do is text.

core-ai-bot commented 3 years ago

Comment by wnr Monday Mar 17, 2014 at 10:34 GMT


Hmm, maybe I'm missing something here but CM does keep track somehow which text to copy to/from clipboard at which cursor, right? Then couldn't the logic that handles that, make sure that when there is a mismatch between number of current selections and copied selections mismatch, then only paste the previously primary selection (i.e. the last one).

Or how do we approach this problem? Clearly it needs to be solved since this is very confusing for users.

core-ai-bot commented 3 years ago

Comment by njx Monday Mar 17, 2014 at 11:14 GMT


Yes, sorry, I was referring to the main bug you filed (my conjecture is this is the reason why it doesn't properly match the pair of selections after your second set of steps). But we could make it so that if there's a mismatch, it only pastes the primary selection. However, I would note that Sublime has the same behavior as CM (if you select two items, then create a single cursor and paste, it pastes both items separated by a newline), so I'm inclined not to change that behavior since it seems to be expected.

core-ai-bot commented 3 years ago

Comment by wnr Monday Mar 17, 2014 at 11:29 GMT


Ah okay, then I understand :)

Yes, I noted the same in Sublime, I should've written that in the issue. However, the behaviour of Sublime is a bit different when you cut a line + a word. Then when you paste, it only pastes the primary selection (last one). So if you reproduce the problematic steps in Sublime, you will not get the same result as in brackets.

The last paragraph in the issue was only a personal opinion, but since Sublime does the same I understand we might wanna go with current behaviour (I'm gonna edit the issue to clarify). But still, the difference as explained above seems like a bug to me.

What do you think?

core-ai-bot commented 3 years ago

Comment by njx Monday Mar 17, 2014 at 11:40 GMT


That is interesting - I'll have to do a little more playing around to understand what the heuristics should be.

core-ai-bot commented 3 years ago

Comment by njx Monday Mar 17, 2014 at 11:41 GMT


Medium priority to me.

core-ai-bot commented 3 years ago

Comment by njx Monday Mar 17, 2014 at 15:10 GMT


@wnr FYI, I just tried both these use cases in both Sublime 3 and Ace (line + word selected, copy, arrow right to keep two selections, paste; line + word selected, copy, set single cursor, paste) and got the same behavior as CM (both line and word pasted) in all cases. The only time I was able to get it to paste different content into each selection was when each selection was smaller than a line, and whenever I set a single selection it always concatenated all the copied content. So it looks like they're both using the same heuristics as CM.

core-ai-bot commented 3 years ago

Comment by njx Monday Mar 17, 2014 at 15:11 GMT


Lowering priority for now.

core-ai-bot commented 3 years ago

Comment by wnr Monday Mar 17, 2014 at 20:52 GMT


Ah you're right! I think my confusion must have been that when you set a cursor on a line and then highlight a word and then copy, I expected it to behave the same way as if I would have selected the line containing the cursor. Instead, when only having a cursor + selected word, it seems to only copy the selected word. Since Ctrl-c with only a cursor copies the whole line, I expected these cases to be equivalent, which is not the case. My bad :)

core-ai-bot commented 3 years ago

Comment by njx Monday Mar 17, 2014 at 21:02 GMT


Got it. Given that, should we go ahead and close this one out?

core-ai-bot commented 3 years ago

Comment by wnr Tuesday Mar 18, 2014 at 09:00 GMT


Yes I think so.

core-ai-bot commented 3 years ago

Comment by njx Tuesday Mar 18, 2014 at 16:14 GMT


OK, thanks - definitely let us know if you have any other suggestions for multiple selection.