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

Recalculate selected code upon copy in submission #5157

Merged
merged 4 commits into from
Nov 16, 2023
Merged

Conversation

jorg-vr
Copy link
Contributor

@jorg-vr jorg-vr commented Nov 15, 2023

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

@jorg-vr jorg-vr added the bug Something isn't working label Nov 15, 2023
@jorg-vr jorg-vr self-assigned this Nov 15, 2023
@jorg-vr jorg-vr requested a review from a team as a code owner November 15, 2023 13:41
@jorg-vr jorg-vr requested review from bmesuere and niknetniko and removed request for a team November 15, 2023 13:41
Copy link
Member

@niknetniko niknetniko left a 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.

Copy link
Member

@bmesuere bmesuere left a 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?

@jorg-vr jorg-vr changed the title Disable copy code hack while writing a comment Recalculate selected code upon copy in submission Nov 15, 2023
@jorg-vr jorg-vr merged commit 816c289 into main Nov 16, 2023
13 checks passed
@jorg-vr jorg-vr deleted the fix/copy-paste-code branch November 16, 2023 10:44
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.

Allow copy-pasting while adding annotations to evaluation
3 participants