Skip to content

Text overdraw maintains ANSI characters from behind #717

Open
@mattprecious

Description

@mattprecious

Failing test:

@Test
fun overdraw() = runTest {
  runMosaicTest(RenderingSnapshots(rendering)) {
    setContent {
      Box {
        Text(
          buildAnnotatedString {
            withStyle(SpanStyle(textStyle = Underline)) {
              append("Hello")
            }
          }
        )

        Text(
          modifier = Modifier.background(Color(0xffffff)),
          value = "World",
        )
      }
    }

    assertThat(awaitSnapshot()).isEqualTo(
      """
      |${CSI}48;2;255;255;255mWorld${CSI}0m
      |
      """.trimMargin().wrapWithAnsiSynchronizedUpdate().replaceLineEndingsWithCRLF(),
    )
  }
}

It's debatable whether this is a bug or not, but explicitly adding a background color to the second text makes it a stronger argument that the underline should be stripped from the merged output. Otherwise, it's not going to be possible to build UIs with z-index.

Removing the background color and just doing Text("World") could also arguably not have an underline in the merged output, but the counter argument is that technically you would still see the underline because it's below the characters. What about Strikethrough and text color though?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions