eclipse-platform / eclipse.platform.swt

Eclipse SWT
https://www.eclipse.org/swt/
Eclipse Public License 2.0
118 stars 137 forks source link

Display.withCrLf() is producing wrong line breaks on Windows #1557

Open Christopher-Hermann opened 2 weeks ago

Christopher-Hermann commented 2 weeks ago

Describe the bug Display.withCrLf() is producing wrong line breaks based on the heuristics in the Windows implementation. This happens only for Strings that contains broken formatting itself. But nevertheless, I think we can fix this issue by improving the method implementation.

To Reproduce See Test case

    @Test
    public void testMixedLfAndCrflOnWindows() {
        if (!SWT.getPlatform().equals("win32")) {
            return;
        }

        String act = Display.withCrLf("First Line \n second line \r\n third line");

        assertEquals("First Line \r\n second line \r\n third line", act);
    }

Expected behavior Expectation is that the method replaces all standalone \n with \r\n. With the given example, \r\n results in \r\r\n

Screenshots If applicable, add screenshots to help explain your problem.

Environment:

  1. Select the platform(s) on which the behavior is seen:
      • [ ] All OS
      • [x] Windows
      • [ ] Linux
      • [ ] macOS
Evgeni-Kramerov commented 2 weeks ago

@Christopher-Hermann Hi, Could you please assign this issue to me, I would love to fix it. Thanks!

HannesWell commented 2 weeks ago

Could you please assign this issue to me, I would love to fix it.

Just assigned it to you, but you can of course also work on an issue even if it hasn't been assigned to you :) Just leave a note that you are working on it to avoid concurrent work.

Btw. if you are looking for a guide to help you through your contribution please try out https://github.com/eclipse-ide, which we are currently building for exactly that situation.