[CLOSED] selectall problem with textmarkers at first and last line


I have a small problem with textmarkers and copy-paste selection. The hidden replaced text is correctly copied in most case except when the textmarkers are located at the first and the last line of the code (it makes thus not possible to insert a new line before the first line or after the last line but it’s an expected behaviour).

Here’s an example: http://jsfiddle.net/tptprmrn/3/ (just select-all, then copy/paste the content in another text editor)

Should I introduce a bug on github or is there any workaround for this special purpose ?


Atomic ranges restrict the valid cursor positions (and replacedWith implies atomic). In your demo, any position between {line: 0, ch: 0} and {line: 0, ch: 19} falls inside of the range at the start of the document, and thus can’t be a cursor position. A similar effect exists with the range at the end. Select-all will try to select the whole document, but then the atomicity-preserving code will push the ends of the selection inwards, past the ranges at both ends of the document.

The solution is probably once again to combine readOnly and atomic ranges – make the start of the document a valid cursor position by giving the range at the start inclusiveLeft: false, and then have a readOnly range spanning that position (leftInclusive: true) so that the user can’t type there. And a similar approach at the end of the document. That way, the selection ends created by selectall are valid, and the whole document can be selected.

OK got it! Thanks!