+8

Editor range selections/caret positioning behaves differently than the rest of OS X's text views do

Shaun Harrison 7 years ago • updated by gscottolson 5 years ago 1

Sublime Text 2 handles text range selections and caret position changes slightly differently than the native OS X text views do. 


Test Case #1:  Open a blank file with a single line with the contents "one two three"

  1. Highlight the word "two" and press the left arrow key while holding shift
    1. Expected OS X behavior: Expand the text selection to the left of "two" by one, resulting in the selected range being " two"
    2. Sublime behavior: Decreases the selection from the right by one, resulting in the selected range being "tw"
    3. Note: This is not the case for shift+right, this works as expected.
  2. Put the caret in the middle of the line, press the up arrow key
    1. Expected behavior: The caret moves to the beginning of the line
    2. Sublime behavior: Nothing happens
  3. Put the caret in the middle of the line, press the down arrow key
    1. Expected behavior: The caret moves to the end of the line
    2. Sublime behavior: Nothing happens 
  4. Highlight "two", press the up arrow key
    1. Expected behavior: The caret moves to the beginning of the line
    2. Sublime behavior: Caret moves to the beginning of the word "two"
  5. Highlight the word "two", press the down arrow key
    1. Expected Behavior: The caret moves to the end of the line
    2. Sublime behavior: The caret moves to the end of the word "two"
  6. Highlight the word "two", press the up arrow key while holding shift
    1. Expected Behavior: It highlights the entire line up until the end of "two" resulting in "one two" being highlighted
    2. Sublime behavior: It highlights the entire line up unto the beginning of "two" resulting in "one " being highlighted
    3. Note: This is not the case for shift+down, it works as expected.
Test Case #2:  Open a blank file with a two lines, both with the contents "one two three"
  1. Highlight the word "two" in the second add line, press the up arrow key while holding shift
    1. Expected behavior: It moves extends the range to select everything from the beginning of two on the first line, to the end of two on the second line, resulting in the selection being "two three\none two"
    2. Sublime behavior: It changes the range to selection everything between "two" on the first line and "two" on the second line, resulting in the selection being " three\none "
    3. Note: This is not the case with shift+down while starting on the first line, this works as expected.
I tested and confirmed "expected behavior" in the following OS X apps:
  • TextEdit
  • TextMate
  • Xcode
  • Espresso 2
  • Chocolat

Great test case write-up. This has been bugging me to no end.