[TxMt] Range of selection string / environment variable TM_SELECTION

Kai Wood lists at kwood.eu
Wed Jan 15 13:57:42 UTC 2014


I’m trying to add some missing functionality to a bundle and stumbled upon some odd behavior of the selection string in TM_SELECTION regarding the range…

When I select a block of text and my cursor is somewhere in the middle of a line, the selection string contains exactly the highlighted range. Consider the following selection (see screenshot):



TM_SELECTION is now "5:5-3”, so lines 3-5 are included.

Example 2, column selection:



TM_SELECTION is “5x3”, lines 3-5 included.

But whenever I’m using CMD-L for “Select line”, like here, it gets somewhat problematic:



TM_SELECTION is now "6-3”, the range now includes line 6, but the *visible* part of the selection is still 3-5.

I can work somewhat around this checking if the last character in TM_SELECTED_TEXT is a newline (\n) (because that is where the additional line in the range is coming from - as one can make the same selection in example 3 when the cursor is on the first row of line 6, holding shift and hitting UP 2 times. Standard OSX behavior). 

But the more I think about it, the less I’m sure if this is intentional.

Can this be considered a bug or is it intended behavior / a feature?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20140115/2fc56a2d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2014-01-15 at 14.17.00.png
Type: image/png
Size: 6604 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20140115/2fc56a2d/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2014-01-15 at 14.33.21.png
Type: image/png
Size: 7308 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20140115/2fc56a2d/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2014-01-15 at 14.18.31.png
Type: image/png
Size: 7378 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20140115/2fc56a2d/attachment-0005.png>


More information about the textmate mailing list