RichTextFX
RichTextFX copied to clipboard
Space between lines after insert text with multiple lines
I upgraded from version 0.7 M5 to version 0.8.2 and found that a white space between the lines is created as soon as multi-line text is inserted by replaceText() - method.
You can see it by the line numbers as shown in the screenshot. I have inserted some text by using the replaceText() in line 9. As a result, a white space appeared in the following lines.
I hope I can reproduce this mistake and send you an executable example soon. But maybe you can give me a hint, why this behavior occures and hopefully give me a workaround ;)
Further information: Mac OS, JDK1.8
I don't think it's an issue with this code. I thought perhaps it might be related to #676, but the line numbers indicate that it's creating multiple paragraphs, not one.
What is the text that you are passing into the argument? It seems like it has one two many \n
characters.
Oh, I think I said it wrong. I don't mean the white space in the code. I mean the 1px high white space between the lines. In the screenshot you can see 1px high white lines which starts at line 9. Have a closure look at the line numbers. There you will see the small distance between the lines best.
This behavior was not like this in version 0.7 M5.
Edit: Maybe lost in translation: by "white space" I don't mean a blank. I mean a distance - a small space - which is just white (as a color) under each line (start at line 9)
Thanks for the clarification. I reread your comment and I think I understand what you mean now.
Here's my wording of your issue:
If one looks at the line numbers to the left of the actual text in the area very closely, one can see that line numbers 1-9 do not have any space separating them. In other words, the gray background color behind the darker gray colored line numbers is not separated by a different color. Although each line uses its own gray box, the boxes are laid out in such a way that they are touching, creating the illusion that only one such box is used between them as a background color.
However, when looking at the space between line numbers 9 and 10, one can see a very small white line. This white line separates the rest of the line numbers (10 - 19, at least; I can't see beyond that). This white line reveals that the gray background behind the line numbers is in fact individual boxes that lie very close to one another and not just one large box covering all the lines.
In 0.7-M5
, this did not occur but it does on 0.8.2
.
Since line 10 is the first line to be a blank line, and you mentioned that this occurs when using a String with multiple lines of text, I'd guess it has something to do with that.
Here's a few questions that might help narrow this quirk down:
- If you deleted the blank line, does the white line disappear?
- If you use a different version of replace (which uses a different version of ReadOnlyStyledDocument's
from[String/Seg/etc]
), does it reproduce/fix the issue? - If you delete everything from line 8 and downward and then add content back to it (via manual typing), does the white line between lines 9 and 10 disappear? Or is it still there? (I'm trying to discern whether the line 'sticks' or not based on a previous edit)
Many thanks for your reply.
It doesnt change if I delete the blank line - i guess the blank line is not the problem. I didn't tell you, that I insert the text by choosing from an option of a popup. To bound the Popup to the caretposition i use
setX(editor.getTranslateX() + editor.getCaretBounds().get().getMaxX())
The issue is gone when i don't set X like that. I figured out, that
editor.getCaretBounds()
is the problem here.
I attached a screenshot just to show what happens when i open the popup.
Have a closure look between line 11 and 12. And after the popup is hidden the following lines get some space too. It does not happen, when i comment-out the above mentioned code as you can see in the following screenshot:
As you can see, the popup is above the editor now, but the small space between the lines is gone.
Edit: Same issue occures in 0.7 M5 when I use the above mentioned line of code. In 0.7 I can use
this.editor.setPopupAtCaret(this)
as workaround. But this way is marked as deprecated and gone in 0.8.2
Ok, thanks for narrowing the issue down further.
Can you create a demo that reproduces the issue?
@ITrun90 Did you ever figure out what was causing the issue? Or did you ever create a reproducible demo?