Skip to content

Commit 885e149

Browse files
authored
Merge pull request #1 from madhavpcm/restartTest
Restart test using <Tab> + <Enter>
2 parents 07a923d + 9acd43b commit 885e149

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type model struct {
2121

2222
done bool
2323
fistChar bool
24+
prevKey string
2425
}
2526

2627
type row struct {

main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,22 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
6262
// Keyboard input
6363
case tea.KeyMsg:
6464
switch msg.Type {
65+
case tea.KeyTab:
66+
if !m.done {
67+
m.prevKey = "tab"
68+
}
69+
6570
case tea.KeyEnter:
6671
// new Sentence creation and States reset
67-
if m.done {
72+
if m.done || m.prevKey == "tab"{
6873
m.sentence = generator.Sentence()
6974
m.runeCount = utf8.RuneCountInString(m.sentence)
7075
m.done = false
7176
m.fistChar = true
77+
m.prevKey = ""
7278
}
7379

80+
7481
case tea.KeyEscape, tea.KeyCtrlC:
7582
// bay bay
7683
return m, tea.Quit
@@ -109,6 +116,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
109116
m.termHeight = msg.Height
110117
}
111118

119+
120+
112121
return m, nil
113122
}
114123

0 commit comments

Comments
 (0)