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: copy the current formats when insertings a character #187

Merged
merged 5 commits into from
Apr 11, 2023

Conversation

jrmd
Copy link
Contributor

@jrmd jrmd commented Feb 27, 2023

Description of the Change

Previously we would just insert the character at the point, however, when a character was inserted within a text format they would split the format and insert the character with no formats.

With this commit we copy the current value and insert out character here which preserves the surrounding formatting

Old Behaviour

Old.Insert.Behaviour.mov

New Behaviour

New.Behaviour.mov

How to test the Change

Create some text with a text format (bold/italic) put cursor in the middle add a special character ensure that the format isnt split by the special character

Changelog Entry

Fixed - Maintain text formatting when inserting a character.

Credits

@jrmd

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

Previously we would just insert the character at the point, however,
when a character was inserted within a text format they would split the
format and insert the character with no formats.

With this commit we copy the current `value` and insert out character
here which preserves the surrounding formatting
@jrmd jrmd requested a review from a team as a code owner February 27, 2023 11:17
@jrmd jrmd requested review from Sidsector9 and removed request for a team February 27, 2023 11:17
Copy link
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

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

Thank you very much for the PR!

I tested the changes and it has worked partially for me.

The formatting doesn't seem to work when the string is partially formatted.

Please watch the 2 videos below:

Working

ISC-W.mp4

Not working

ISC-NW.mp4

Let us know if you need any assistance with this PR.

Updates newValue.formats to be the length of the new text string by
duplicating the formats at value.start; this fixes an issue where it
breaks the remaining format if it is added within the middle
@jrmd
Copy link
Contributor Author

jrmd commented Feb 28, 2023

hey @Sidsector9 thanks for testing! I believe i have fixed this by copying the current positions formats :)

Screen.Recording.2023-02-28.at.11.29.29.mov

@jrmd jrmd requested a review from Sidsector9 February 28, 2023 15:07
@jeffpaul
Copy link
Member

@jrmd welcome to Insert Special Characters and thanks for the PR, this is definitely a nice improvement in maintaining formatting... many thanks for the contribution!

@jeffpaul jeffpaul added this to the 1.0.7 milestone Feb 28, 2023
@jeffpaul jeffpaul added the type:bug Something isn't working. label Feb 28, 2023
tests/bin/initialize.sh Outdated Show resolved Hide resolved
@jrmd jrmd requested a review from Sidsector9 March 1, 2023 10:56
@jeffpaul jeffpaul merged commit f8497d1 into 10up:develop Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants