fix bug not allowing Q to be typed in settings

This commit is contained in:
Rasmus Wejlgaard 2025-11-08 19:01:42 +00:00
parent 3c7b64417b
commit 3819ce0bce
3 changed files with 9 additions and 23 deletions

2
go.mod
View file

@ -3,6 +3,7 @@ module github.com/rwejlgaard/org
go 1.25.3 go 1.25.3
require ( require (
github.com/BurntSushi/toml v1.5.0
github.com/alecthomas/chroma/v2 v2.20.0 github.com/alecthomas/chroma/v2 v2.20.0
github.com/charmbracelet/bubbles v0.21.0 github.com/charmbracelet/bubbles v0.21.0
github.com/charmbracelet/bubbletea v1.3.10 github.com/charmbracelet/bubbletea v1.3.10
@ -10,7 +11,6 @@ require (
) )
require ( require (
github.com/BurntSushi/toml v1.5.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect

View file

@ -18,17 +18,6 @@ const (
settingsSectionKeybindings settingsSectionKeybindings
) )
// settingsState tracks the state of the settings editor
type settingsState struct {
section settingsSection
cursor int
scroll int
editing bool
editingField string
editingValue string
modified bool
}
// initSettings initializes the settings state // initSettings initializes the settings state
func (m *uiModel) initSettings() { func (m *uiModel) initSettings() {
m.settingsCursor = 0 m.settingsCursor = 0
@ -42,7 +31,7 @@ func (m *uiModel) updateSettings(msg tea.Msg) (tea.Model, tea.Cmd) {
// If editing, handle text input // If editing, handle text input
if m.textinput.Focused() { if m.textinput.Focused() {
switch { switch {
case key.Matches(msg, m.keys.Quit): case msg.Type == tea.KeyEsc:
m.textinput.Blur() m.textinput.Blur()
return m, nil return m, nil
case msg.Type == tea.KeyEnter: case msg.Type == tea.KeyEnter:
@ -439,11 +428,11 @@ func (m *uiModel) viewSettings() string {
var instructions string var instructions string
switch m.settingsSection { switch m.settingsSection {
case settingsSectionTags: case settingsSectionTags:
instructions = "←/→: Switch tabs • ↑/↓: Navigate • Enter: Edit • D: Deletec: Add new tag • ctrl+s: Save • q/,: Exit" instructions = "←/→: Switch tabs • ↑/↓: Navigate • Enter: Edit • D: Delete\nc: Add new tag • ctrl+s: Save • q/,: Exit"
case settingsSectionStates: case settingsSectionStates:
instructions = "←/→: Switch tabs • ↑/↓: Navigate • shift+↑/↓: Reorder • Enter: EditD: Delete • c: Add new state • ctrl+s: Save • q/,: Exit" instructions = "←/→: Switch tabs • ↑/↓: Navigate • shift+↑/↓: Reorder • Enter: Edit\nD: Delete • c: Add new state • ctrl+s: Save • q/,: Exit"
case settingsSectionKeybindings: case settingsSectionKeybindings:
instructions = "←/→: Switch tabs • ↑/↓: Navigate • Enter: Edit keybindingctrl+s: Save • q/,: Exit" instructions = "←/→: Switch tabs • ↑/↓: Navigate • Enter: Edit keybinding\nctrl+s: Save • q/,: Exit"
} }
content.WriteString(m.styles.statusStyle.Render(instructions) + "\n\n") content.WriteString(m.styles.statusStyle.Render(instructions) + "\n\n")
@ -461,7 +450,7 @@ func (m *uiModel) viewSettings() string {
if m.textinput.Focused() { if m.textinput.Focused() {
content.WriteString("\n") content.WriteString("\n")
content.WriteString(m.textinput.View() + "\n") content.WriteString(m.textinput.View() + "\n")
content.WriteString(m.styles.statusStyle.Render("Enter: Save • ESC/q: Cancel") + "\n") content.WriteString(m.styles.statusStyle.Render("Enter: Save • ESC: Cancel") + "\n")
} }
return content.String() return content.String()
@ -535,7 +524,7 @@ func (m *uiModel) viewSettingsStates() string {
// State name with its color // State name with its color
stateStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(state.Color)) stateStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(state.Color))
line += stateStyle.Render(fmt.Sprintf("%s", state.Name)) line += stateStyle.Render(state.Name)
line += fmt.Sprintf(" (color: %s)", state.Color) line += fmt.Sprintf(" (color: %s)", state.Color)
content.WriteString(line + "\n") content.WriteString(line + "\n")
@ -613,7 +602,7 @@ func (m *uiModel) updateSettingsAddTag(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
switch { switch {
case key.Matches(msg, m.keys.Quit): case msg.Type == tea.KeyEsc:
m.textinput.Blur() m.textinput.Blur()
m.mode = modeSettings m.mode = modeSettings
return m, nil return m, nil
@ -664,7 +653,7 @@ func (m *uiModel) updateSettingsAddState(msg tea.Msg) (tea.Model, tea.Cmd) {
} }
switch { switch {
case key.Matches(msg, m.keys.Quit): case msg.Type == tea.KeyEsc:
m.textinput.Blur() m.textinput.Blur()
m.mode = modeSettings m.mode = modeSettings
return m, nil return m, nil

View file

@ -32,9 +32,6 @@ func (d dynamicKeyMap) FullHelp() [][]key.Binding {
func (m uiModel) renderFullHelp() string { func (m uiModel) renderFullHelp() string {
bindings := m.keys.getAllBindings() bindings := m.keys.getAllBindings()
// Estimate the width needed for each keybinding (key + desc + padding)
// Average is roughly 20-25 chars per binding
const estimatedBindingWidth = 22
const minWidth = 40 // Minimum width before stacking const minWidth = 40 // Minimum width before stacking
var columnsPerRow int var columnsPerRow int