Skip to content

End point of selection should not be included #147

Open
oskusalerma opened this Issue Mar 25, 2012 · 0 comments

1 participant

@oskusalerma
Owner

Our selection logic does not match what other text editors do, and makes it impossible to implement a thin cursor.

The problem is that the end-point of the selection is inclusive, whereas it should be exclusive. So if you set the mark at line 0, column 0, and keep the cursor at the same location, right now in Trelby that means that the first character is selected. That can somehow be justified when using a block cursor, but if you're using a thin cursor that's to the left of the character, it makes no sense. It also is not how emacs works, which also has a block cursor.

There are two approaches to fixing this:

  • Make Screenplay.getMarkedLines/Columns return value semantics stay the same (inclusive), only return one less character as end point.
    • Problem: How do we mark empty lines then? We can't return -1 as column.
  • Change the semantics of those two return values to be exclusive for the end-point, and change all callers to deal with that change.

The second option looks like the right thing to do.

See discussion at #143 for history of how this was discovered.

@ElecProg ElecProg added a commit that referenced this issue Nov 24, 2015
@ElecProg ElecProg This fixes #44 and fixes #147: Thin cursor setting and selection beha…
…vior.

This adds a setting for a block cursor (default) or thin cursor and
changes selection behavior accordingly.
Also fixes selection behavior of both cursors at the end of the (top)
line.
1d4a03f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.