sapphirehamster wrote:This is not correct, as randy3k said just above. The "cursor" is at region.end().
Wrong. region.end() gives you the side of the region closest to the end of the buffer. region.b is the cursor.
To demonstrate, open a view in sublime, make a few lines, then drag select from the end of the view to the beginning. Your "cursor" (the blinking dot) will be at the beginning of the view, while the selection will span to the end of the view.
Open the console and run this:
- Code: Select all
print(view.size(), view.sel().b, view.sel().end())
view.size() will equal region.end() and *not* region.b.
region.end() is only accurate when you do selections toward the end of the view, and wrong when you do selections toward the beginning of the view.
You should also be careful of using (region.begin(), region.end()) to save and restore cursor state, as you will potentially reverse the selection (like using abs() on a negative number).