[jedit:bugs] #4125 Delete at the end of the line does not delete newline (java20, java21)
Eric Le Lay via jEdit-devel <[email protected]> Tue, 03 Oct 2023 06:22:48 -0000
| Newsgroups | gmane.editors.jedit.devel |
|---|---|
| Message-ID | </p/jedit/bugs/4125/b02990b60bb04f4a43b7daf83ed17438cac365cc.bugs@jedit.p.sourceforge.net> |
The fix by Dale seems good: we always want to delete at least a char.
But I would prefer we put it in the `TextArea.nextOf()` method, with a detailed comment, because with the new `GraphemeBreakIterator` the logic to detect an end of line is broken and the existing comment would mislead people in this already complicated area of the code.
~~~~
diff --git a/org/gjt/sp/jedit/textarea/TextArea.java b/org/gjt/sp/jedit/textarea/TextArea.java
index 9ce126e49..2f98a897a 100644
--- a/org/gjt/sp/jedit/textarea/TextArea.java
+++ b/org/gjt/sp/jedit/textarea/TextArea.java
@@ -6314,10 +6314,12 @@ loop: for(int i = lineNo - 1; i >= 0; i--)
{
int following = charBreaker.following(offset -
index0Offset);
- if (following == BreakIterator.DONE)
+ if (following == BreakIterator.DONE || (following == offset - index0Offset))
{
- // This means a end of line. Then it is
- // safe to assume 1 code unit is a character.
+ // When offset is before a line break,
+ // pre java20 BreakIterator.DONE is returned by RuleBasedBreakIterator
+ // after java20, offset - index0Offset is returned by GraphemeBreakIterator.
+ // Then it is safe to assume 1 code unit is a character.
// This may return an offset beyond the
// length of buffer. But it is a callers
// responsibility.
~~~~
Here is my mail to jedit-devel for the record: https://sourceforge.net/p/jedit/mailman/message/40461293/
---
**[bugs:#4125] Delete at the end of the line does not delete newline (java20, java21)**
**Status:** open
**Group:** normal bug
**Created:** Sun Jun 04, 2023 12:51 PM UTC by Alan Ezust
**Last Updated:** Wed Sep 20, 2023 03:28 PM UTC
**Owner:** Matthieu Casanova
If I am at the end of a line and I hit delete, the newline char is not deleted anymore.
Using jedit 5.6.0, openjdk 20 or 21 on kubuntu linux 22.04.
Switching to openjdk 19 makes the problem go away.
---
Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/jedit/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/jedit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
--
-----------------------------------------------
jEdit Developers' List
[email protected]
https://lists.sourceforge.net/lists/listinfo/jedit-devel