feat: improve textbox editor behaviour

This commit is contained in:
2026-07-31 15:36:23 +02:00
parent b24669e604
commit e36b00f741
15 changed files with 504 additions and 154 deletions

View File

@@ -29,17 +29,18 @@ func (m *App) startPREdit() tea.Cmd {
}
m.writeMode = writePREdit
m.prEditField = prEditBodyField
m.prEditEditors[prEditTitleField] = newTextEditor(m.details.Title, false)
m.prEditEditors[prEditBaseField] = newTextEditor(m.details.BaseRef, false)
modal := m.editorMode == "vim"
m.prEditEditors[prEditTitleField] = newTextEditor(m.details.Title, modal)
m.prEditEditors[prEditBaseField] = newTextEditor(m.details.BaseRef, modal)
m.prEditEditors[prEditReviewersField] = newTextEditor(
strings.Join(m.details.RequestedReviewers, ", "), false,
strings.Join(m.details.RequestedReviewers, ", "), modal,
)
m.prEditEditors[prEditAssigneesField] = newTextEditor(
strings.Join(m.details.Assignees, ", "), false,
strings.Join(m.details.Assignees, ", "), modal,
)
m.prEditEditors[prEditBodyField] = newTextEditor(
normalizeLineEndings(m.details.Body),
m.editorMode == "vim",
modal,
)
m.prEditEditors[prEditBodyField].highlightMarkdown = true
m.prEditOriginal = m.currentPRMetadata()
@@ -168,7 +169,9 @@ func (m App) updatePREditInput(key tea.KeyMsg) (tea.Model, tea.Cmd) {
}
return m, nil
}
if key.Type == tea.KeySpace && m.prEditField == prEditReviewersField {
if key.Type == tea.KeySpace && m.prEditField == prEditReviewersField &&
(!m.prEditEditors[m.prEditField].Modal ||
m.prEditEditors[m.prEditField].Mode == textEditorInsert) {
if m.startNextReviewer() {
m.ensurePREditCursorVisible()
return m, m.queuePREditDraft()
@@ -195,13 +198,7 @@ func (m App) updatePREditInput(key tea.KeyMsg) (tea.Model, tea.Cmd) {
return m, nil
}
case "tab":
completed := m.prEditField == prEditBaseField && m.completeBranchSuggestion()
if isPREditPeopleField(m.prEditField) {
completed = m.completeUserSuggestion()
}
if !completed {
m.movePREditField(1)
}
m.movePREditField(1)
case "shift+tab":
m.movePREditField(-1)
case "ctrl+n":
@@ -548,7 +545,6 @@ func (m App) dashboardEditLayout() ([]string, int) {
func (m App) prEditFieldLines(label string, field, width int) []string {
active := m.prEditField == field
editor := m.prEditEditors[field]
if field == prEditReviewersField {
label += " (pending requests editable)"
}
@@ -556,10 +552,6 @@ func (m App) prEditFieldLines(label string, field, width int) []string {
if active {
prefix = "▶ "
}
mode := editor.modeLabel()
if mode != "" {
label += " [" + mode + "]"
}
labelLine := dimStyle.Render(prefix + label)
if active {
labelLine = titleStyle.Render(prefix + label)