(state: CommandState)
| 56 | |
| 57 | /** Decide what Enter does. Pure, and the only place that decides it. */ |
| 58 | export function commandIntent(state: CommandState): CommandIntent { |
| 59 | const trimmed = state.line.trim(); |
| 60 | if (trimmed.length === 0) { |
| 61 | return 'nothing'; |
| 62 | } |
| 63 | if (looksLikeQuestion(trimmed)) { |
| 64 | return 'ask'; |
| 65 | } |
| 66 | if (state.hitCount > 0) { |
| 67 | return 'search-hit'; |
| 68 | } |
| 69 | return state.answered ? 'ask' : 'nothing'; |
| 70 | } |
no test coverage detected