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

Preserve cursor and selection when reopening editors #9557

Merged

Conversation

OmarSdt-EC
Copy link
Contributor

@OmarSdt-EC OmarSdt-EC commented Jun 4, 2021

What it does

Fixes #6016
Fixes #8782

The pull-request attempts to restore the previous editor state when re-opening a closed editor through the quick-file-open.
The editor-view state should preserve folding, selection, cursor location.

How to test

Selection:

  1. open a workspace in the application.
  2. open an editor at a specific line and selection.
  3. close the editor.
  4. re-open the closed editor using ctrlcmd+p.
  5. the editor should re-open with the previous state (cursor and selection).

selection

Folding:

  1. open a workspace in the application.
  2. open an editor.
  3. execute the command fold all (the folding regions of the editor should be collapsed).
  4. close the editor.
  5. re-open the closed editor using ctrlcmd+p.
  6. the editor should re-open with the previous folding state.

test-editor-state

Line and Column:

Thanks to #9478, it is now possible to open files with a pre-defined line number and column. If the line number, or line number and column are provided this should take precedence over restoring the editor.

Review checklist

Reminder for reviewers

@OmarSdt-EC OmarSdt-EC force-pushed the os/feature_preserveCursorPR branch 2 times, most recently from 1349ba5 to 7acb2b7 Compare June 7, 2021 19:40
@OmarSdt-EC OmarSdt-EC changed the title Enhancement : cursor/selection preserved Preserve cursor and selection when reopening editors Jun 7, 2021
@vince-fugnitto vince-fugnitto added enhancement issues that are enhancements to current functionality - nice to haves file search issues related to the file search labels Jun 8, 2021
Copy link
Contributor

@alvsan09 alvsan09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the behavior and it works nicely! 👍
No additional comments on the implementation, well done! :-)

My approval is just symbolic as I am not yet a commiter!

@OmarSdt-EC OmarSdt-EC force-pushed the os/feature_preserveCursorPR branch from 7acb2b7 to f687540 Compare June 14, 2021 13:43
The cursor or the selection is now preserved when we close an editor
and when we use ctrlcmd + p to reopen it. It stays at the location where
we left it and doesn't end up at the beginning of the file like before.
@OmarSdt-EC OmarSdt-EC force-pushed the os/feature_preserveCursorPR branch from f687540 to c7f5eeb Compare June 14, 2021 14:53
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed that the changes work as intended:

  • the editor state is restored if available when performing quick-file-open.
  • the editor state is not preserved if an explicit selection (line number or line number + column) is explicitly requested when opening.
  • the editor state is restored if the editor.history.persistClosedEditors is set to true and we attempt to re-open a previously stored editor.

@vince-fugnitto vince-fugnitto merged commit a5bfd57 into eclipse-theia:master Jun 14, 2021
@vince-fugnitto vince-fugnitto deleted the os/feature_preserveCursorPR branch June 14, 2021 15:36
@vince-fugnitto vince-fugnitto added this to the 1.15.0 milestone Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement issues that are enhancements to current functionality - nice to haves file search issues related to the file search
Projects
None yet
4 participants