RemoveHyperlinks Action deletes entire text instead of only removing hyperlink

General TRichView support forum. Please post your questions here
Post Reply
tomr
Posts: 42
Joined: Wed Dec 09, 2020 9:36 am

RemoveHyperlinks Action deletes entire text instead of only removing hyperlink

Post by tomr »

Hello TRichView Support,
after running the RemoveHyperlinks action, both the hyperlink and its text are removed. I can reproduce this behavior in your RichViewActionTest demo.

Steps to reproduce:
Start the RichViewActionTest program. The sample text is displayed as expected.
RichviewActionTestLinks.png
RichviewActionTestLinks.png (39.95 KiB) Viewed 361 times
Select the hyperlink in the text and execute the RemoveHyperlinks action.
Remove Hyperlinks 1.png
Remove Hyperlinks 1.png (20.2 KiB) Viewed 361 times
→ The hyperlink is removed, and the text appears with the default formatting. This works as intended.
Text ohne Hyperlink.png
Text ohne Hyperlink.png (6.69 KiB) Viewed 361 times
Now insert the link www.google.com and press Enter. It is correctly displayed as a hyperlink.
Hyperlink erstell.png
Hyperlink erstell.png (8.2 KiB) Viewed 361 times
Select this newly created hyperlink and run the RemoveHyperlinks action again.
Remove Hyperlinks 2.png
Remove Hyperlinks 2.png (20.24 KiB) Viewed 361 times
→ This time, the entire text is deleted.

Is there a way to remove only the hyperlink without deleting the text?
Sergey Tkachenko
Site Admin
Posts: 17995
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: RemoveHyperlinks Action deletes entire text instead of only removing hyperlink

Post by Sergey Tkachenko »

I confirm the problem. A fixed version will be released soon.
Quick fix:
Open RichViewActions.pas.
Find the code:

Code: Select all

        if AllowChangingText and (StartNo = EndNo) and
          (rve.GetItemStyle(i) >= 0) and
          (rve.GetItemTag(i) = rve.GetItemTextW(i)) then
        begin
          rve.SetItemTextEd(i, String(NewTag));
change to:

Code: Select all

        if AllowChangingText and (NewTag <> '') and (StartNo = EndNo) and
          (rve.GetItemStyle(i) >= 0) and
          (rve.GetItemTag(i) = rve.GetItemTextW(i)) then
        begin
          rve.SetItemTextEdW(i, NewTag);
tomr
Posts: 42
Joined: Wed Dec 09, 2020 9:36 am

Re: RemoveHyperlinks Action deletes entire text instead of only removing hyperlink

Post by tomr »

Hi Sergey,
thank you for your help. I implemented the quickfix and everything is working fine. :D
Post Reply