Skip to content

Commit 125208f

Browse files
authored
feat(tui/login): add ctrl+v password visibility toggle (#685)
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
1 parent c9da429 commit 125208f

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

tui/login.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ func (m *Login) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
176176
case "esc":
177177
return m, func() tea.Msg { return GoToChoiceMenuMsg{} }
178178

179+
case "ctrl+v":
180+
// Toggle password visibility while focused on the password field,
181+
// so typos in app-passwords are catchable without retyping.
182+
if m.focusIndex == inputPassword {
183+
if m.inputs[inputPassword].EchoMode == textinput.EchoPassword {
184+
m.inputs[inputPassword].EchoMode = textinput.EchoNormal
185+
} else {
186+
m.inputs[inputPassword].EchoMode = textinput.EchoPassword
187+
}
188+
return m, nil
189+
}
190+
179191
case "enter":
180192
m.updateFlags()
181193
visible := m.visibleFields()
@@ -417,7 +429,11 @@ func (m *Login) View() tea.View {
417429
if !m.hideTips && tip != "" {
418430
views = append(views, TipStyle.Render("Tip: "+tip))
419431
}
420-
views = append(views, helpStyle.Render("\nenter: save • tab: next field • esc: back to menu"))
432+
helpLine := "enter: save • tab: next field • esc: back to menu"
433+
if m.focusIndex == inputPassword {
434+
helpLine += " • ctrl+v: toggle password visibility"
435+
}
436+
views = append(views, helpStyle.Render("\n"+helpLine))
421437

422438
return tea.NewView(lipgloss.JoinVertical(lipgloss.Left, views...))
423439
}

0 commit comments

Comments
 (0)