MCPcopy
hub / github.com/yorukot/superfile / HandleUpdate

Method HandleUpdate

src/internal/ui/prompt/model.go:40–64  ·  view source on GitHub ↗
(msg tea.Msg, cwdLocation string)

Source from the content-addressed store, hash-verified

38}
39
40func (m *Model) HandleUpdate(msg tea.Msg, cwdLocation string) (common.ModelAction, tea.Cmd) {
41 var action common.ModelAction
42 action = common.NoAction{}
43 var cmd tea.Cmd
44 if !m.IsOpen() {
45 slog.Error("HandleUpdate called on closed prompt")
46 return action, cmd
47 }
48
49 switch msg := msg.(type) {
50 case tea.KeyPressMsg:
51 switch {
52 case slices.Contains(common.Hotkeys.ConfirmTyping, msg.String()):
53 action = m.handleConfirm(cwdLocation)
54 case slices.Contains(common.Hotkeys.CancelTyping, msg.String()):
55 m.Close()
56 default:
57 cmd = m.handleNormalKeyInput(msg)
58 }
59 default:
60 // Non keypress updates like Cursor Blink
61 m.textInput, cmd = m.textInput.Update(msg)
62 }
63 return action, cmd
64}
65
66func (m *Model) handleConfirm(cwdLocation string) common.ModelAction {
67 // Pressing confirm on empty prompt will trigger close

Callers 1

TestModel_HandleUpdateFunction · 0.45

Calls 7

IsOpenMethod · 0.95
handleConfirmMethod · 0.95
CloseMethod · 0.95
handleNormalKeyInputMethod · 0.95
UpdateMethod · 0.80
StringMethod · 0.65
ErrorMethod · 0.45

Tested by 1

TestModel_HandleUpdateFunction · 0.36