Re: deleting next newline character in java 21 (linux)

Dale Anson <[email protected]> Mon, 2 Oct 2023 15:46:21 -0600
Newsgroups gmane.editors.jedit.devel
Message-ID <CAHrA0wBX=hwn+ySsa8p4wX6oOy10Lq13R1JLeSNK-gP5L5Fzzw@mail.gmail.com>
https://sourceforge.net/p/jedit/bugs/4125/ covers this issue. Now that
you've pinpointed the source of the problem, I think the fix I mentioned on
that bug is probably sufficient. Yes?

On Mon, Oct 2, 2023 at 12:38 PM Eric Le Lay <[email protected]>
wrote:

> The problem is a changed BreakIterator implementation [1]
>
> - before openjdk 20 it was sun.util.locale.provider.RuleBasedBreakIterator
> - after, it is
> sun.util.locale.provider.BreakIteratorProviderImpl$GraphemeBreakIterator
>
> RuleBasedBreakIterator.following() returns DONE when we are at the last
> character of the line (next character is new line)
> GraphemeBreakIterator.following() returns the current offset when we are
> at the last character of the line.
>
> Here is a patch to fix it on openjdk:
>
> diff --git a/org/gjt/sp/jedit/textarea/TextArea.java
> b/org/gjt/sp/jedit/textarea/TextArea.java
> index 9ce126e49..13214008b 100644
> --- a/org/gjt/sp/jedit/textarea/TextArea.java
> +++ b/org/gjt/sp/jedit/textarea/TextArea.java
> @@ -6314,7 +6314,7 @@ loop:             for(int i = lineNo - 1; i >= 0;
> i--)
>                 {
>                         int following = charBreaker.following(offset -
>                                         index0Offset);
> -                       if (following == BreakIterator.DONE)
> +                       if (following == BreakIterator.DONE ||
> (Runtime.version().feature() >= 20 && following == offset - index0Offset))
>                         {
>                                 // This means a end of line. Then it is
>                                 // safe to assume 1 code unit is a
> character.
>
>
> I don't know the code in TextArea and I can't vouch for it working
> correctly with characters above BMP.
> If k_satoda is still around, I would really appreciate the help.
>
> Also I hope the condition on Runtime.version().feature() is inlined by the
> JIT compiler but a better solution should be considered.
>
> Please anybody help on this: I think it should be fixed for jEdit 5.7
> release...
>
> Cheers,
>
> [1] https://bugs.openjdk.org/browse/JDK-8291660
>
> Le Fri, 2 Jun 2023 15:15:10 -0600,
> Dale Anson <[email protected]> a écrit :
>
> > I tried the KeyEventDemo from Oracle. I made a minor adjustment to use
> > a text area instead of a text field in the demo to be able to test
> > delete at the end of a line. The delete key in the demo works fine.
> > I've attached the demo code if you want to try it out.
> >
> > I guess this means the problem is in jEdit, not in Java.
> >
> > On Fri, Jun 2, 2023 at 2:51 PM Dale Anson <[email protected]> wrote:
> > >
> > > I'm not finding anything by googling about this. I did find that if
> > > I press Ctrl-Delete at the end of the line that it works like I
> > > would expect Delete by itself to work. It seems the delete key works
> > > correctly everywhere except at the end of a line. I'm testing with
> > > Java 20.
> > >
> > > On Fri, Jun 2, 2023 at 9:48 AM Alan Ezust <[email protected]>
> > > wrote:
> > > >
> > > > I can confirm the same problem exists in openJDK 20 (linux). Do
> > > > we work around it in jEdit or do we try to report it as a bug in
> > > > openjdk, I wonder?
> > > >
> > > > On Wed, May 31, 2023 at 11:20 AM Alan Ezust
> > > > <[email protected]> wrote:
> > > >>
> > > >> I just tried jEdit with java21 and now the "delete" character no
> > > >> longer works if I am at the end of the line - i expect it to
> > > >> delete the newline and it just doesn't. switching to java 19
> > > >> makes the problem go away.
> > > > --
> > > > -----------------------------------------------
> > > > jEdit Developers' List
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/jedit-devel
>
>

-- 
-----------------------------------------------
jEdit Developers' List
[email protected]
https://lists.sourceforge.net/lists/listinfo/jedit-devel