Fix AE in scratch for long lines

^KT-24638 Fixed
This commit is contained in:
Natalia Selezneva
2018-05-31 12:25:41 +03:00
parent ccacf1bd23
commit 62929ba6f5
4 changed files with 18 additions and 10 deletions
@@ -69,7 +69,8 @@ object InlayScratchOutputHandler : ScratchOutputHandler {
fun addInlay(text: String) {
val textBeforeNewLine = if (StringUtil.containsLineBreak(text)) text.substringBefore("\n") + "..." else text
val shortText = StringUtil.shortenTextWithEllipsis(textBeforeNewLine, maxLineLength - spaceCount - lineLength, 0)
val maxInlayLength = (maxLineLength - spaceCount - lineLength).takeIf { it > 5 } ?: 5
val shortText = StringUtil.shortenTextWithEllipsis(textBeforeNewLine, maxInlayLength, 0)
if (shortText != text) {
printToToolWindow(file, expression, output)
}
+9 -5
View File
@@ -1,8 +1,12 @@
val a = "a".repeat(100) // RESULT: val a: String
a // RESULT: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
val b = "0123456789\n".repeat(10) // RESULT: val b: String
b // RESULT: 0123456789; 0123456789; 0123456789; 0123456789; 0123456789; 0123456789; 01234567...
val a = "a".repeat(100) // RESULT: val a: String
a // RESULT: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
val b = "0123456789\n".repeat(10) // RESULT: val b: String
b // RESULT: 0123456789; 0123456789; 0123456789; 0123456789; 012345678...
println("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789") // OUTPUT: 01...
/** veryLongOutput.kts:2 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa */
/** veryLongOutput.kts:4 0123456789 */
/** veryLongOutput.kts:4 0123456789 */
/** veryLongOutput.kts:4 0123456789 */
/** veryLongOutput.kts:4 0123456789 */
/** veryLongOutput.kts:4 0123456789 */
/** veryLongOutput.kts:4 0123456789 */
/** veryLongOutput.kts:5 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 */
+2 -1
View File
@@ -1,4 +1,5 @@
val a = "a".repeat(100)
a
val b = "0123456789\n".repeat(10)
b
b
println("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789")
+5 -3
View File
@@ -1,7 +1,8 @@
val a = "a".repeat(100)
a // RESULT: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
a // RESULT: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
val b = "0123456789\n".repeat(10)
b // RESULT: 0123456789...
b // RESULT: 0123456789...
println("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789") // OUTPUT: 01...
/** veryLongOutput.kts:2 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa */
/** veryLongOutput.kts:4 0123456789
0123456789
@@ -12,4 +13,5 @@ b // RESULT: 0123456789...
0123456789
0123456789
0123456789
0123456789 */
0123456789 */
/** veryLongOutput.kts:5 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 */