AvaloniaEdit icon indicating copy to clipboard operation
AvaloniaEdit copied to clipboard

Word wrap artificially wraps line after new VisualLineElement

Open mattj23 opened this issue 2 years ago • 7 comments

It appears that, when word wrap is active, breaking a line with a new VisualLineElement causes the line to wrap immediately after that element.

The easiest way to see this is to launch the AvaloniaEdit.Demo project, turn on word wrap, scroll to line 41 and add the text "https://test" in the middle of the string literal. On both an Arch Linux system and a Windows 10 system I get an unintended line break immediately after the end of the URL, where a VisualLineLinkText element has been inserted by its respective generator. I've also observed this behavior with a custom class that inherited from VisualLineElement (this is how I discovered the behavior) so I know it's not just the link element which does it.

I'm working on a minimum reproducible project so that I can try to take a closer look at what's happening, but I wanted to check in case someone already had an idea what might be happening and have a good idea how to fix it.

Otherwise, between this and @Gillibald's comment in #223 regarding virtualizing line text maybe the word wrap feature could use some attention? I'd be happy to try to dig in and contribute here, though the codebase is pretty large and I find I'm spending most of my time sort of wandering through it. If some effort here would be welcome I would be very appreciative of anyone who could point me in the direction of even where to start looking.

mattj23 avatar Apr 16 '22 20:04 mattj23

Word wrap on, before adding URL: image

After adding URL: image

Note there's no carriage return after the URL...here it is with word wrap turned off: image

mattj23 avatar Apr 16 '22 20:04 mattj23

Word wrap algorithm is completely new in PR #216. Could you try if now it behaves as expected?

danipen avatar Apr 16 '22 20:04 danipen

Sure thing, this is commit b11e3be2? Branch feature/TextFormatterPort?

mattj23 avatar Apr 16 '22 20:04 mattj23

Yes.

danipen avatar Apr 16 '22 20:04 danipen

I need to make sure I'm not messing something up, but it does seem to work correctly on Windows, but somehow not on Linux. Give me a few minutes to clone everything clean and confirm.

mattj23 avatar Apr 16 '22 20:04 mattj23

Ok! Yes, everything works correctly in b11e3be on both Windows and Linux. I was getting mixed up with multiple clones. Thanks for the quick response and I apologize for not digging deeper on my own.

Do you want me to close this issue now or leave it open until PR #216 gets merged?

mattj23 avatar Apr 16 '22 20:04 mattj23

Let's keep it open until that PR is merged

Gillibald avatar Apr 16 '22 21:04 Gillibald

Can close now.

danipen avatar Oct 06 '22 07:10 danipen