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

fix(#1545): Split Editor Causes Hang #1565

Merged
merged 4 commits into from
Jan 16, 2024

Conversation

thecoolwinter
Copy link
Collaborator

Description

Fixes a bug where opening the same file in a split editor would cause an infinite hang. The hang was caused by both editors in the split sharing a single published cursorPositions variable. When one editor was unfocused, it would try to set that variable to be empty, but it was immediately updated by the newly focused editor to contain a new cursor position. This led to an infinite loop of both editors attempting to update the shared variable.

To fix, I've added the notion of an 'instance' of an editor. There's now three levels of abstraction for a single editor:

  • CEWorkspaceFile: Basically a pointer to a file, does not read contents.
  • CodeFileDocument: For reading / writing a file, contains the contents of the file.
  • EditorInstance: Manages a single visual instance of an editor, including published cursor positions or other injected objects.
    The editor manager now manages editor instances instead of files.

I'd have liked to have #1564 merged before this one, but there are other problems with the CI making it take longer than expected, so this can be merged before that.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

N/A

- Adds `OpenOptions` to `CodeFileDocument`
- Adds a new `EditorInstance` observable class to represent tabs for files instead of just `CEWorkspaceFile`
- Refactors to use new `EditorInstance` everywhere.
Copy link
Collaborator

@0xWDG 0xWDG left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@austincondiff austincondiff left a comment

Choose a reason for hiding this comment

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

Great work! Love the new EditorInstance class!

@austincondiff austincondiff merged commit 36eaac7 into CodeEditApp:main Jan 16, 2024
2 checks passed
@thecoolwinter thecoolwinter added the bug Something isn't working label Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐞 Opening file in split editor causes infinite hang
3 participants