[go: nahoru, domu]

Merge "Fix invalidate range check for lineIndex" into androidx-master-dev
diff --git a/ui/ui-text-core/src/androidAndroidTest/kotlin/androidx/ui/text/MultiParagraphIntegrationTest.kt b/ui/ui-text-core/src/androidAndroidTest/kotlin/androidx/ui/text/MultiParagraphIntegrationTest.kt
index 04ea5ed..8c54adf 100644
--- a/ui/ui-text-core/src/androidAndroidTest/kotlin/androidx/ui/text/MultiParagraphIntegrationTest.kt
+++ b/ui/ui-text-core/src/androidAndroidTest/kotlin/androidx/ui/text/MultiParagraphIntegrationTest.kt
@@ -640,6 +640,20 @@
     }
 
     @Test
+    fun lineContentForEmptyText() {
+        val text = ""
+        val paragraph = simpleMultiParagraph(text = text)
+
+        assertThat(paragraph.lineCount).isEqualTo(1)
+        assertThat(paragraph.getLineStart(0)).isEqualTo(0)
+        assertThat(paragraph.getLineEnd(0)).isEqualTo(0)
+        assertThat(paragraph.getLineLeft(0)).isEqualTo(0)
+        assertThat(paragraph.getLineRight(0)).isEqualTo(0)
+        assertThat(paragraph.getLineEllipsisCount(0)).isEqualTo(0)
+        assertThat(paragraph.getLineEllipsisOffset(0)).isEqualTo(0)
+    }
+
+    @Test
     fun getLineRight() {
         with(defaultDensity) {
             val text = createAnnotatedString("aa", "\u05D0\u05D0")
diff --git a/ui/ui-text-core/src/commonMain/kotlin/androidx/ui/text/MultiParagraph.kt b/ui/ui-text-core/src/commonMain/kotlin/androidx/ui/text/MultiParagraph.kt
index b7c4795..9b30ec4 100644
--- a/ui/ui-text-core/src/commonMain/kotlin/androidx/ui/text/MultiParagraph.kt
+++ b/ui/ui-text-core/src/commonMain/kotlin/androidx/ui/text/MultiParagraph.kt
@@ -501,7 +501,7 @@
 
     /** Returns the start offset of the given line, inclusive. */
     fun getLineStart(lineIndex: Int): Int {
-        requireIndexInRange(lineIndex)
+        requireLineIndexInRange(lineIndex)
 
         val paragraphIndex = findParagraphByLineIndex(paragraphInfoList, lineIndex)
 
@@ -512,7 +512,7 @@
 
     /** Returns the end offset of the given line, exclusive. */
     fun getLineEnd(lineIndex: Int): Int {
-        requireIndexInRange(lineIndex)
+        requireLineIndexInRange(lineIndex)
 
         val paragraphIndex = findParagraphByLineIndex(paragraphInfoList, lineIndex)
 
@@ -523,7 +523,7 @@
 
     /** Returns the offset where ellipsis is applied, regarding to the line start. */
     fun getLineEllipsisOffset(lineIndex: Int): Int {
-        requireIndexInRange(lineIndex)
+        requireLineIndexInRange(lineIndex)
 
         val paragraphIndex = findParagraphByLineIndex(paragraphInfoList, lineIndex)
 
@@ -534,7 +534,7 @@
 
     /** Returns the number of characters that is ellipsized in the line. */
     fun getLineEllipsisCount(lineIndex: Int): Int {
-        requireIndexInRange(lineIndex)
+        requireLineIndexInRange(lineIndex)
 
         val paragraphIndex = findParagraphByLineIndex(paragraphInfoList, lineIndex)