@@ -559,7 +559,7 @@ class StormfrontClient(
559
559
} else {
560
560
doAppendToStream(styledText, stream, ignoreWhenBlank)
561
561
}
562
- if (stream == mainStream || windows[ stream.name]?.styleIfClosed == " main " ) {
562
+ if (stream == mainStream || ifClosedStream( stream) == mainStream ) {
563
563
isPrompting = false
564
564
val text = styledText.toString()
565
565
if (text.isNotBlank()) {
@@ -573,10 +573,10 @@ class StormfrontClient(
573
573
if (ignoreWhenBlank && styledText.isBlank())
574
574
return
575
575
stream.appendLine(styledText, ignoreWhenBlank)
576
- doIfClosed(stream.name ) { targetStream ->
577
- val currentWindow = windows[stream.name]
576
+ doIfClosed(stream) { targetStream ->
577
+ val style = windows[stream.name]?.styleIfClosed
578
578
targetStream.appendLine(
579
- text = currentWindow?.styleIfClosed ?.let { styledText.applyStyle(WarlockStyle (it)) } ? : styledText,
579
+ text = style ?.let { styledText.applyStyle(WarlockStyle (it)) } ? : styledText,
580
580
ignoreWhenBlank = ignoreWhenBlank
581
581
)
582
582
}
@@ -598,16 +598,24 @@ class StormfrontClient(
598
598
buffer = null
599
599
}
600
600
601
- private suspend fun doIfClosed (streamName : String , action : suspend (TextStream ) -> Unit ) {
602
- val currentWindow = windows[streamName]
603
- if (currentWindow != null ) {
604
- val ifClosed = currentWindow.ifClosed ? : " main"
605
- if (ifClosed != streamName && ifClosed.isNotBlank() && ! openWindows.value.contains(streamName)) {
606
- action(getStream(ifClosed))
601
+ private suspend fun doIfClosed (stream : TextStream , action : suspend (TextStream ) -> Unit ) {
602
+ if (! openWindows.value.contains(stream.name)) {
603
+ ifClosedStream(stream)?.let { closedStream ->
604
+ action(closedStream)
607
605
}
608
606
}
609
607
}
610
608
609
+ private fun ifClosedStream (stream : TextStream ): TextStream ? {
610
+ val window = windows[stream.name] ? : return null
611
+ val ifClosedName = window.ifClosed ? : " main"
612
+ return if (stream.name != ifClosedName && ifClosedName.isNotBlank()) {
613
+ getStream(ifClosedName)
614
+ } else {
615
+ null
616
+ }
617
+ }
618
+
611
619
override suspend fun sendCommand (line : String , echo : Boolean ): SendCommandType {
612
620
if (echo) {
613
621
printCommand(line)
0 commit comments