Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions modules/core/src/main/scala/InteractiveMultipleChoice.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ private[cue4s] class InteractiveMultipleChoice(
lines += "? ".focused + lab.prompt + s" $promptCue ".prompt + st.text.input
lines += "Tab".emphasis + " to toggle, " + "Shift+Tab".emphasis + " to toggle all, " + "Enter".emphasis + " to submit."

status match
case Status.Running(Left(err)) =>
lines += err.error
case _ =>

st.display.showing match
case None =>
lines += "no matches...".noMatches
Expand Down Expand Up @@ -95,6 +90,12 @@ private[cue4s] class InteractiveMultipleChoice(
end if
end match

status match
case Status.Running(Left(err)) =>
lines += err.error
case _ =>
lines += ""

case Status.Finished(ids) =>
lines += s"$promptDone ".focused + lab.prompt

Expand Down
17 changes: 13 additions & 4 deletions modules/core/src/main/scala/PromptFramework.scala
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ trait PromptFramework[Result](terminal: Terminal, out: Output)
state: PromptState,
status: Status,
): List[String] =
self.renderState(state, self.currentStatus())
val innerStatus = status match
case Status.Running(Left(err)) => self.Status.Running(Left(err))
case _ => self.currentStatus()
self.renderState(state, innerStatus)

override def handleEvent(
event: Event,
Expand All @@ -163,6 +166,10 @@ trait PromptFramework[Result](terminal: Terminal, out: Output)
case self.PromptAction.Update(statusChange, stateChange) =>
self.stateTransition(stateChange, statusChange)

val innerWasFinished = self.currentStatus() match
case self.Status.Finished(_) => true
case _ => false

val refinedStatus =
self.currentStatus() match
case self.Status.Finished(result) =>
Expand All @@ -174,12 +181,14 @@ trait PromptFramework[Result](terminal: Terminal, out: Output)
case self.Status.Running(r) => Status.Running(r.flatMap(f))
case self.Status.Init => Status.Init

// propagate information backwards...
// When outer validation rejects a Finished result,
// reset the inner to Init so it can accept new events
// and doesn't carry stale error status
refinedStatus match
case Status.Running(Left(err)) =>
case Status.Running(Left(_)) if innerWasFinished =>
self.stateTransition(
identity,
_ => self.Status.Running(Left(err)),
_ => self.Status.Init,
)
case _ =>

Expand Down
6 changes: 6 additions & 0 deletions modules/core/src/snapshots/core/alternatives_cancel_multiple
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Event.Init
┃ ◯ sweet potato ┃
┃ ◯ fried chicken ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(TAB)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -17,6 +18,7 @@ Event.Key(TAB)
┃ ◯ sweet potato ┃
┃ ◯ fried chicken ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(DOWN)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -27,6 +29,7 @@ Event.Key(DOWN)
┃ ◯ sweet potato ┃
┃ ◯ fried chicken ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(TAB)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -37,6 +40,7 @@ Event.Key(TAB)
┃ ◯ sweet potato ┃
┃ ◯ fried chicken ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(DOWN)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -47,6 +51,7 @@ Event.Key(DOWN)
┃ ◯ sweet potato ┃
┃ ◯ fried chicken ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Interrupt
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -57,4 +62,5 @@ Event.Interrupt
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Event.Init
┃ ◉ sweet potato ┃
┃ ◉ fried chicken ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(TAB)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -17,28 +18,29 @@ Event.Key(TAB)
┃ ◉ sweet potato ┃
┃ ◉ fried chicken ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(ENTER)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃? What would you like for lunch › ┃
┃Tab to toggle, Shift+Tab to toggle all, Enter to submit.┃
┃show pizza some love! ┃
┃ ◯ pizza ┃
┃ ◉ steak ┃
┃ ◉ sweet potato ┃
┃ ◉ fried chicken ┃
┃show pizza some love! ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(TAB)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃? What would you like for lunch › ┃
┃Tab to toggle, Shift+Tab to toggle all, Enter to submit.┃
┃show pizza some love! ┃
┃ ◉ pizza ┃
┃ ◉ steak ┃
┃ ◉ sweet potato ┃
┃ ◉ fried chicken ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(ENTER)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand Down
10 changes: 10 additions & 0 deletions modules/core/src/snapshots/core/alternatives_infiniscroll_multiple
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Event.Init
┃ ◯ steak ┃
┃ ↓ sweet potato ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(TAB)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -15,6 +16,7 @@ Event.Key(TAB)
┃ ◯ steak ┃
┃ ↓ sweet potato ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(DOWN)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -24,6 +26,7 @@ Event.Key(DOWN)
┃ ◯ steak ┃
┃ ↓ sweet potato ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(TAB)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -33,6 +36,7 @@ Event.Key(TAB)
┃ ◉ steak ┃
┃ ↓ sweet potato ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(DOWN)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -42,6 +46,7 @@ Event.Key(DOWN)
┃ ◯ sweet potato ┃
┃ ↓ fried chicken ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(DOWN)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -51,6 +56,7 @@ Event.Key(DOWN)
┃ ◯ fried chicken ┃
┃ ◯ sushi ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(TAB)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -60,6 +66,7 @@ Event.Key(TAB)
┃ ◉ fried chicken ┃
┃ ◯ sushi ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(DOWN)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -69,6 +76,7 @@ Event.Key(DOWN)
┃ ◉ fried chicken ┃
┃ ◯ sushi ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(TAB)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -78,6 +86,7 @@ Event.Key(TAB)
┃ ◉ fried chicken ┃
┃ ◉ sushi ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Event.Key(ENTER)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Expand All @@ -87,4 +96,5 @@ Event.Key(ENTER)
┃ ◉ fried chicken ┃
┃ ◉ sushi ┃
┃ ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Loading
Loading