copy/paste of collapsed ranges

when copying/pasting lines with collapsed ranges, the collapsed ranges get pasted as well.

to reproduce:
If in the CM pane press ctrl+a ctrl+c ctrl+end ctrl+v

you will that the second and third lines are pasted with their collapsed ranges (now visible/not collapsed)

is this the intended behavior or a bug ? I would expect the collapsed ranges to either not be copied at all or be pasted as a collapsed range.

is there a way to make collapsed ranges ‘truly’ hidden in the sense that they will not be copied ?


This is the intended behavior. The clipboard holds plain text, with no information about collapsed state.

Thx, I understand the clipboard should not hold information about collapsed state.

However why do the collapsed ranges get copied at all ? that is very surprising behaviour to have the collapsed ranges ‘exposed’ on copy/paste.

Is there a way to not include them in a copy operation ? perhaps a new marked text flag.

Rationale - Firepad adds a line ‘sentinel’ implemented as a collapsed range to the beginning of each line. This is used internally for the operation-transform model. Because of the above, copy/paste of FP text adds all the line sentinels to the clipboard which is essentially a bug when pasting in ie notepad. I am looking for a way to solve this.

Collapsed ranges represent text. If you want sentinels, you’re probably better off using bookmarks instead.

Changing the internals of FP OT model is too involved for me unfortunately. Also I don’t think bookmarks will work as sentinels as it is essential for them to behave like invisible text.

“Collapsed ranges represent text”, well they represent collapsed text, which to me as a user you don’t expect to suddenly appear when you paste it somewhere else.

Also the behavior in the plunkr above is confusing. The first collapsed range is not copied (I guess because it is not ‘selected’) where as the other two do.

Basically, I am asking if it is possible to have a way to created collapsed ranges which do not get copied to the clipboard ? that would be very helpful and intuitive.

You don’t need to change your OT model, you can just change the way you create the data you feed into it. I am not really interested in adding features to work around hacks in other projects.

As for ‘intuitive’, the main use case for collapsed/replaced ranges are code folding and replacing a piece of text with an equivalent widget. Both of them require the content to be copied when selected.