Skip to content

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

@Christopher-Hermann

Description

@Christopher-Hermann

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
    • Windows
    • Linux
    • macOS

Metadata

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions