Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor position is not stored when changing lines #748

Closed
james-whiteside opened this issue Jun 14, 2023 · 0 comments · Fixed by #749
Closed

Cursor position is not stored when changing lines #748

james-whiteside opened this issue Jun 14, 2023 · 0 comments · Fixed by #749

Comments

@james-whiteside
Copy link
Member

james-whiteside commented Jun 14, 2023

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: 23a5011
  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.
jamesreprise pushed a commit that referenced this issue Apr 12, 2024
## What is the goal of this PR?

We store cursor positions when changing lines as described in
#748. This is standard
behaviour in other IDEs, such as IntelliJ IDEA and VSCode.

## What are the changes implemented in this PR?

We store an additional piece of data in `Cursor`, `lastCol`. This
remembers the last position of the column, which we only forget upon the
creation of a new cursor by a method other than moving up or down a
line.

## Additional info
Closes #748
@sync-by-unito sync-by-unito bot reopened this May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants