typedb / typedb-studio

TypeDB Studio (IDE)
https://typedb.com
Mozilla Public License 2.0
191 stars 44 forks source link

Cursor position is not stored when changing lines #748

Closed james-whiteside closed 5 months ago

james-whiteside commented 1 year ago

Description

When using the directional keys to navigate, two cursor column positions should be used: an absolute position and a display position. The display position is always the same as the absolute position, unless the line does not have enough characters, in which case the display position is the last available position on that line.

Using up or down should move the cursor to the same position on the line immediately above or below respectively. If the line does not have enough characters to accomodate the cursor at that position, it should be displayed at the last available position instead, but the stored absolute position should not change. If the cursor is then moved again using up or down then the cursor should attempt to return to the stored absolute position, and fallback to the last available position as before. The up and down keys should never change the absolute position of the cursor, except when used on the first or last line respectively, when the absolute position is changed to the first or last available position on the line respectively.

Using left or right should move the cursor left or right one character, unless at the start or end of the line respectively, in which case the cursor should wrap around the the next available line. If the cursor's absolute position is different to its display position when left or right are used, the absolute position should then be updated to match the display position.

Environment

  1. TypeDB version: 2.18.0
  2. OS of TypeDB server: MacOS 12.6.1
  3. Studio version: 23a501103bc8a2eb514967dc8c2ad36ddb5b5df9
  4. OS of Studio: MacOS 12.6.1

Reproducible Steps

  1. Create a file in the query editor with three lines of length 20, 10, and 30 characters respectively.

Scenario 1:

  1. Place the cursor at the end of the first (20 char) line.
  2. Use left to move the cursor one position to the left.
  3. Use down to move the cursor to the second (10 char) line.
  4. Use down to move the cursor to the third (30 char) line.

Scenario 2:

  1. Place the cursor at the end of the first (20 char) line.
  2. Use left to move the cursor one position to the left.
  3. Use down to move the cursor to the second (10 char) line.
  4. Use left to move the cursor one position to the left.
  5. Use down to move the cursor to the third (30 char) line.

Expected Output

Scenario 1:

  1. Cursor at line position 20.
  2. Cursor at line position 19.
  3. Cursor at line position 10.
  4. Cursor at line position 19.

Scenario 2:

  1. Cursor at line position 20.
  2. Cursor at line position 19.
  3. Cursor at line position 10.
  4. Cursor at line position 9.
  5. Cursor at line position 9.

Actual Output

Scenario 1:

  1. Cursor at line position 20.
  2. Cursor at line position 19.
  3. Cursor at line position 10.
  4. Cursor at line position 10.

Scenario 2:

  1. Cursor at line position 20.
  2. Cursor at line position 19.
  3. Cursor at line position 10.
  4. Cursor at line position 9.
  5. Cursor at line position 9.