-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Recalculate selected code upon copy in submission #5157
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my limited testing, copying while the annotation form was open did not result in a log of cases where there were extra newlines or duplicate code, so I'm not sure how big a problem this is, and if it warrants the bigger refactor or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would maybe keep this solution for now and wait for further feedback in the future before refactoring?
This pull request recalculates the selection when a copy event is triggered. This makes the code copy independent of the selectedRange tracked for the annotation form.
I had to improve the offset calculation a bit, because it did not work correctly if the focusnode itself was a PRE element (instead of a textnode child of a pre element). Now it should be more general and support both cases.
I also disabled range modification when triggered by the copy call. In the other use case the selection is being modified directly after creation which feels intuitive. But when it happens on copy it feels strange, and there is no good reason to do it. So I turned it off in that case.
Closes #5155