Skip to content

Commit f45a870

Browse files
committed
small fix
1 parent 12d76a2 commit f45a870

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

cmd/formatter/shortcut.go

+8-12
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (lk *LogKeyboard) PrintKeyboardInfo(print func()) {
139139
print()
140140

141141
if lk.logLevel == INFO {
142-
lk.createBuffer(1)
142+
lk.createBuffer(0)
143143
lk.printNavigationMenu()
144144
}
145145
}
@@ -148,18 +148,16 @@ func (lk *LogKeyboard) PrintKeyboardInfo(print func()) {
148148
func (lk *LogKeyboard) createBuffer(lines int) {
149149
allocateSpace(lines)
150150

151-
if lk.kError.shoudlDisplay() && isOverflow(lk.kError.error()) {
151+
if lk.kError.shoudlDisplay() {
152152
extraLines := linesOffset(lk.kError.error()) + 1
153153
allocateSpace(extraLines)
154154
lines = lines + extraLines
155155
}
156156

157157
infoMessage := lk.navigationMenu()
158-
if isOverflow(infoMessage) {
159-
extraLines := linesOffset(infoMessage) + 1
160-
allocateSpace(extraLines)
161-
lines = lines + extraLines
162-
}
158+
extraLines := linesOffset(infoMessage) + 1
159+
allocateSpace(extraLines)
160+
lines = lines + extraLines
163161

164162
if lines > 0 {
165163
MoveCursorUp(lines)
@@ -272,7 +270,10 @@ func (lk *LogKeyboard) HandleKeyEvents(event keyboard.KeyEvent, ctx context.Cont
272270
switch key := event.Key; key {
273271
case keyboard.KeyCtrlC:
274272
keyboard.Close()
273+
275274
lk.clearNavigationMenu()
275+
ShowCursor()
276+
276277
lk.logLevel = NONE
277278
if lk.Watch.Watching && lk.Watch.Cancel != nil {
278279
lk.Watch.Cancel()
@@ -285,7 +286,6 @@ func (lk *LogKeyboard) HandleKeyEvents(event keyboard.KeyEvent, ctx context.Cont
285286
return nil
286287
})(ctx)
287288
}()
288-
ShowCursor()
289289
// will notify main thread to kill and will handle gracefully
290290
lk.signalChannel <- syscall.SIGINT
291291
case keyboard.KeyEnter:
@@ -303,10 +303,6 @@ func allocateSpace(lines int) {
303303
}
304304
}
305305

306-
func isOverflow(s string) bool {
307-
return lenAnsi(s) > goterm.Width()
308-
}
309-
310306
func linesOffset(s string) int {
311307
return int(math.Floor(float64(lenAnsi(s)) / float64(goterm.Width())))
312308
}

0 commit comments

Comments
 (0)