@@ -57,7 +57,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
57
57
case tea.KeyMsg :
58
58
m , cmd = m .handleKeyInput (msg , cmd )
59
59
}
60
-
60
+
61
61
m .updateFilePanelsState (msg , & cmd )
62
62
m .sidebarModel .directories = getDirectories ()
63
63
@@ -196,20 +196,27 @@ func (m model) handleKeyInput(msg tea.KeyMsg, cmd tea.Cmd) (model, tea.Cmd){
196
196
}
197
197
198
198
func (m * model ) updateFilePanelsState (msg tea.Msg , cmd * tea.Cmd ) {
199
+ focusPanel := & m .fileModel .filePanels [m .filePanelFocusIndex ]
199
200
if m .firstTextInput {
200
201
m .firstTextInput = false
201
202
} else if m .fileModel .renaming {
202
- m .fileModel .filePanels [m .filePanelFocusIndex ].rename , * cmd = m .fileModel .filePanels [m .filePanelFocusIndex ].rename .Update (msg )
203
- } else if m .fileModel .filePanels [m .filePanelFocusIndex ].searchBar .Focused () {
204
- m .fileModel .filePanels [m .filePanelFocusIndex ].searchBar , * cmd = m .fileModel .filePanels [m .filePanelFocusIndex ].searchBar .Update (msg )
203
+ focusPanel .rename , * cmd = focusPanel .rename .Update (msg )
204
+ } else if focusPanel .searchBar .Focused () {
205
+ focusPanel .searchBar , * cmd = focusPanel .searchBar .Update (msg )
206
+ for _ , hotkey := range hotkeys .SearchBar {
207
+ if hotkey == focusPanel .searchBar .Value () {
208
+ focusPanel .searchBar .SetValue ("" )
209
+ break
210
+ }
211
+ }
205
212
} else if m .commandLine .input .Focused () {
206
213
m .commandLine .input , * cmd = m .commandLine .input .Update (msg )
207
214
} else if m .typingModal .open {
208
215
m .typingModal .textInput , * cmd = m .typingModal .textInput .Update (msg )
209
216
}
210
217
211
- if m . fileModel . filePanels [ m . filePanelFocusIndex ] .cursor < 0 {
212
- m . fileModel . filePanels [ m . filePanelFocusIndex ] .cursor = 0
218
+ if focusPanel .cursor < 0 {
219
+ focusPanel .cursor = 0
213
220
}
214
221
}
215
222
@@ -261,38 +268,31 @@ func (m model) View() string {
261
268
finalRender := lipgloss .JoinVertical (0 , mainPanel , footer )
262
269
263
270
// check if need pop up modal
271
+ overlayX := m .fullWidth / 2 - modalWidth / 2
272
+ overlayY := m .fullHeight / 2 - m .helpMenu .height / 2
273
+
264
274
if m .helpMenu .open {
265
275
helpMenu := m .helpMenuRender ()
266
- overlayX := m .fullWidth / 2 - m .helpMenu .width / 2
267
- overlayY := m .fullHeight / 2 - m .helpMenu .height / 2
268
276
return stringfunction .PlaceOverlay (overlayX , overlayY , helpMenu , finalRender )
269
277
}
270
278
271
279
if firstUse {
272
280
introduceModal := m .introduceModalRender ()
273
- overlayX := m .fullWidth / 2 - m .helpMenu .width / 2
274
- overlayY := m .fullHeight / 2 - m .helpMenu .height / 2
275
281
return stringfunction .PlaceOverlay (overlayX , overlayY , introduceModal , finalRender )
276
282
}
277
283
278
284
if m .typingModal .open {
279
285
typingModal := m .typineModalRender ()
280
- overlayX := m .fullWidth / 2 - modalWidth / 2
281
- overlayY := m .fullHeight / 2 - modalHeight / 2
282
286
return stringfunction .PlaceOverlay (overlayX , overlayY , typingModal , finalRender )
283
287
}
284
288
285
289
if m .warnModal .open {
286
290
warnModal := m .warnModalRender ()
287
- overlayX := m .fullWidth / 2 - modalWidth / 2
288
- overlayY := m .fullHeight / 2 - modalHeight / 2
289
291
return stringfunction .PlaceOverlay (overlayX , overlayY , warnModal , finalRender )
290
292
}
291
293
292
294
if m .confirmToQuit {
293
295
warnModal := m .warnModalRender ()
294
- overlayX := m .fullWidth / 2 - modalWidth / 2
295
- overlayY := m .fullHeight / 2 - modalHeight / 2
296
296
return stringfunction .PlaceOverlay (overlayX , overlayY , warnModal , finalRender )
297
297
}
298
298
0 commit comments