Skip to content

Commit

Permalink
fix: Clean up logging around composite editor slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-he committed Jul 1, 2024
1 parent 1e03ae5 commit a1376e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion internal/control/edit/editors/composite_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (e *Composite) getCurrentFieldIndex() int {

// SwitchToNextField switches to the next field (wrapping araound, if necessary)
func (e *Composite) SwitchToNextField() {
log.Trace().Interface("fieldOrder", e.fieldOrder).Msgf("switching to next field")
prevID := e.activeFieldID
indexOfCurrent := e.getCurrentFieldIndex()
nextIndex := (indexOfCurrent + 1) % len(e.fieldOrder)
Expand Down
15 changes: 9 additions & 6 deletions internal/ui/panes/composite_editor_ui_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (p *CompositeEditorPane) Draw() {
for i, id := range fieldOrderSlice {
subpane, ok := p.subpanes[id]
if !ok {
log.Warn().Msgf("comp: subpane '%s' (%d of %d) not found in subpanes (%v)", id, i, len(fieldOrderSlice), p.subpanes)
p.log.Warn().Msgf("subpane '%s' (%d of %d) not found in subpanes (%v)", id, i, len(fieldOrderSlice), p.subpanes)
} else {
subpane.Draw()
}
Expand Down Expand Up @@ -95,7 +95,7 @@ func (p *CompositeEditorPane) Undraw() {
func (p *CompositeEditorPane) ProcessInput(key input.Key) bool {
if p.InputProcessor != nil && p.InputProcessor.CapturesInput() {
if p.isInField() {
p.log.Warn().Msgf("comp: somehow, comosite editor is capturing input despite being in field; likely logic error")
p.log.Warn().Msg("somehow, comosite editor is capturing input despite being in field; likely logic error")
}
return p.InputProcessor.ProcessInput(key)
}
Expand All @@ -104,23 +104,26 @@ func (p *CompositeEditorPane) ProcessInput(key input.Key) bool {
editorID := p.getFocussedEditorID()
focussedSubpane, ok := p.subpanes[editorID]
if !ok {
p.log.Error().Msgf("comp: somehow, have an invalid focussed pane '%s' not in (%v)", editorID, p.subpanes)
p.log.Error().Msgf("somehow, have an invalid focussed pane '%s' not in (%v)", editorID, p.subpanes)
return false
}
processedBySubpane := focussedSubpane.ProcessInput(key)
if processedBySubpane {
return true
}
p.log.Warn().Msgf("comp: input '%s' was not processed by active subeditor pane; will not be processed", key.ToDebugString())
p.log.Warn().
Str("key", key.ToDebugString()).
Str("active-subeditor", string(focussedSubpane.Identify())).

Check failure on line 116 in internal/ui/panes/composite_editor_ui_pane.go

View workflow job for this annotation

GitHub Actions / build

conversion from PaneID (uint) to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
Msg("input was not processed by active subeditor pane; will not be processed")
return false
}

if p.InputProcessor == nil {
p.log.Warn().Msg("comp: input processor is nil; will not process input")
p.log.Warn().Msg("input processor is nil; will not process input")
return false
}

p.log.Trace().Msgf("comp: processing input '%s' self", key.ToDebugString())
p.log.Trace().Str("key", key.ToDebugString()).Msg("processing input self")
return p.InputProcessor.ProcessInput(key)
}

Expand Down

0 comments on commit a1376e4

Please sign in to comment.