Conversation
Wrapping leaves the selection on the word itself, inside the markers it just
added. The toggle then asked whether the selected text starts and ends with the
marker, which is false in exactly the state the first press produces, so a
second press wrapped the wrapped text:
Unidentified -> **Unidentified** -> ****Unidentified****
The toggle now also looks immediately outside the selection, and removes the
markers it finds there.
Markers that continue into more of the same character are left alone, because
they belong to a longer run and so to a different construct. Pressing Italic on
a word inside '**bold**' therefore adds its own markers, giving '***word***',
rather than taking half the bold away.
The fix is in the shared editor model, so both the VCL and FMX editors get it.
Three tests, written first and confirmed failing with the reported strings.
Author
|
Withdrawing this for now: it needs more work before it is worth your time. I will reopen or resubmit once it is verified end to end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Independent of #7, #8, #9, #10 and #11. Cut from
main.The bug
Select a word, press Bold, press Bold again:
The second press should have removed the markers.
The cause
WrapOrToggledeliberately leaves the selection on the word itself, inside the markers it has just added:The toggle branch then asks whether the selected text starts and ends with the marker. In the state the first press produces it does not, so the command falls through and wraps again. The toggle only ever worked if you selected the markers yourself, which is not where the first press leaves you.
The fix
The toggle now also looks immediately outside the selection, and strips the markers it finds there.
One case is deliberately left alone. A marker that continues into more of the same character belongs to a longer run, and therefore to a different construct: the single asterisks either side of a word inside
**bold**are the bold, not an italic waiting to be removed. Pressing Italic there adds its own markers and gives***word***.Because this lives in the shared editor model, both the VCL and FMX editors are fixed by it.
Testing
Three tests, each written before the fix and confirmed failing with the exact reported strings.
Suite: 1087 tests, all passing, no regressions. All three projects build clean on Win32 Debug with Delphi 12 Athens.
Verified in the running studio by toggling with the keyboard and saving after each press: wraps, unwraps, wraps again.