The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 02:45 UTC
fix(mobile): keep Android file icons on the line with wrapped filenames (#11234)
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Dara Adedeji committed
Sep 11, 2026 at 19:22 UTC
cd64ad384e40988f57e4caa5a3f74f25ca5ef450
4 files changed
+75
-5
apps/mobile/modules/t3-markdown-text/android/build.gradle
+12
@@ -8,6 +8,10 @@ android {
8
namespace 'expo.modules.t3markdowntext'
9
compileSdk rootProject.ext.compileSdkVersion
10
11
+ testOptions {
12
+ unitTests.includeAndroidResources = true
13
+ }
14
+
15
defaultConfig {
16
minSdkVersion rootProject.ext.minSdkVersion
17
targetSdkVersion rootProject.ext.targetSdkVersion
@@ -17,4 +21,12 @@ android {
21
dependencies {
22
implementation project(':expo-modules-core')
23
implementation 'com.facebook.react:react-android'
24
+ testImplementation 'junit:junit:4.13.2'
25
+ testImplementation 'org.robolectric:robolectric:4.16.1'
26
+}
27
+
28
+tasks.withType(Test).configureEach {
29
+ javaLauncher = javaToolchains.launcherFor {
30
+ languageVersion = JavaLanguageVersion.of(21)
31
+ }
32
}
apps/mobile/modules/t3-markdown-text/android/src/main/java/expo/modules/t3markdowntext/T3MarkdownTextSelectionModule.kt
+9
-5
@@ -28,19 +28,23 @@ private object MarkdownSpannableFactory : Spannable.Factory() {
28
SpannableStringBuilder(source)
29
}
30
31
-private fun copyTextWithoutInlineImages(
31
+internal fun copyTextWithoutInlineImages(
32
text: CharSequence,
33
start: Int,
34
end: Int
35
): String {
36
if (text !is Spanned) return text.subSequence(start, end).toString()
37
38
+ fun isInlineImage(index: Int): Boolean =
39
+ index >= 0 && text[index].toString() == OBJECT_REPLACEMENT_CHARACTER &&
40
+ text.getSpans(index, index + 1, ReplacementSpan::class.java).isNotEmpty()
41
+
42
return buildString {
43
for (index in start until end) {
40
- val isInlineImage =
41
- text[index].toString() == OBJECT_REPLACEMENT_CHARACTER &&
42
- text.getSpans(index, index + 1, ReplacementSpan::class.java).isNotEmpty()
43
- if (!isInlineImage) append(text[index])
44
+ // The renderer inserts one NBSP after each image to keep its label on the same line.
45
+ // Inspect the original text even when selection starts after the image.
46
+ val isIconSpacer = text[index] == '\u00A0' && isInlineImage(index - 1)
47
+ if (!isInlineImage(index) && !isIconSpacer) append(text[index])
48
}
49
}
50
}
apps/mobile/modules/t3-markdown-text/android/src/test/java/expo/modules/t3markdowntext/MarkdownSelectionCopyTest.kt
new
+48
@@ -0,0 +1,48 @@
1
+package expo.modules.t3markdowntext
2
+
3
+import android.graphics.drawable.ColorDrawable
4
+import android.text.SpannableString
5
+import android.text.Spanned
6
+import android.text.style.ImageSpan
7
+import org.junit.Assert.assertEquals
8
+import org.junit.Test
9
+import org.junit.runner.RunWith
10
+import org.robolectric.RobolectricTestRunner
11
+import org.robolectric.annotation.Config
12
+
13
+@RunWith(RobolectricTestRunner::class)
14
+@Config(sdk = [36], manifest = Config.NONE)
15
+class MarkdownSelectionCopyTest {
16
+ private fun withIcon(value: String): SpannableString = SpannableString(value).apply {
17
+ val index = value.indexOf('\uFFFC')
18
+ setSpan(ImageSpan(ColorDrawable()), index, index + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
19
+ }
20
+
21
+ @Test
22
+ fun removesIconAndInjectedSpacer() {
23
+ val text = withIcon("\uFFFC\u00A0main.go:12 starts the server.")
24
+ assertEquals("main.go:12 starts the server.", copyTextWithoutInlineImages(text, 0, text.length))
25
+ }
26
+
27
+ @Test
28
+ fun removesSpacerWhenSelectionStartsAfterIcon() {
29
+ val text = withIcon("\uFFFC\u00A0main.go:12 starts the server.")
30
+ assertEquals("main.go:12", copyTextWithoutInlineImages(text, 1, 12))
31
+ }
32
+
33
+ @Test
34
+ fun preservesAuthoredWhitespaceAndLiteralObjectCharacters() {
35
+ val text = withIcon("before\u00A0 \uFFFC\u00A0\u00A0 main.go after\u00A0\uFFFC\u00A0")
36
+ assertEquals(
37
+ "before\u00A0 \u00A0 main.go after\u00A0\uFFFC\u00A0",
38
+ copyTextWithoutInlineImages(text, 0, text.length)
39
+ )
40
+ }
41
+
42
+ @Test
43
+ fun preservesTextWithoutImageSpans() {
44
+ val text = "\uFFFC\u00A0main.go"
45
+ assertEquals(text, copyTextWithoutInlineImages(text, 0, text.length))
46
+ assertEquals(text, copyTextWithoutInlineImages(SpannableString(text), 0, text.length))
47
+ }
48
+}
apps/mobile/modules/t3-markdown-text/src/NativeMarkdownSelectableText.tsx
+6
@@ -222,6 +222,12 @@ export function NativeMarkdownSelectableText(props: {
222
}
223
}
224
225
+ // Android renders the icon as an inline Image before the text. A regular space
226
+ // lets the line break between them, stranding the icon on the previous line.
227
+ if (Platform.OS === "android" && (run.fileIcon || linkIcon)) {
228
+ text = `\u00A0${text}`;
229
+ }
230
+
231
return { key: `${signature}:${occurrence}`, run, text, linkIcon };
232
});
233
// T3MarkdownText only rebuilds its attributed string during native layout. A