Skip to content

Commit 89dbe36

Browse files
committed
[fix] show entire selected log when bottom sticky
1 parent 6144e86 commit 89dbe36

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

dev/flask/app.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,17 @@ def exit_after_delay():
8787
# exit_thread = threading.Thread(target=exit_after_delay, daemon=True)
8888
# exit_thread.start()
8989

90+
def generate_random_text(num_words):
91+
words = ['hello', 'world', 'test', 'random', 'text', 'words', 'generator',
92+
'python', 'code', 'sample']
93+
return ' '.join(random.choices(words, k=num_words))
94+
9095
def periodic_logger():
96+
flag = True
9197
while True:
92-
logger.info("Periodic log message")
93-
time.sleep(0.05)
98+
logger.info(generate_random_text(100 if flag else 200))
99+
time.sleep(0.5)
100+
flag = not flag
94101

95102
# Start the periodic logging thread
96103
# logging_thread = threading.Thread(target=periodic_logger, daemon=True)
@@ -106,11 +113,6 @@ def health():
106113
logger.info("LAST Lorem ipsum \n\tdolor sit amet, consectetur adipiscing elit. \n\tSed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad \n\tminim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.")
107114
return jsonify({"status": "healthy"}), 200
108115

109-
def generate_random_text(num_words):
110-
words = ['hello', 'world', 'test', 'random', 'text', 'words', 'generator',
111-
'python', 'code', 'sample']
112-
return ' '.join(random.choices(words, k=num_words))
113-
114116
@app.route("/status", methods=["GET"])
115117
def status():
116118
logger.debug("Status endpoint called")

internal/viewport/viewport.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ func (m *Model[T]) SetContent(content []T) {
309309
m.selectedItemIdx = 0
310310
} else if stayAtBottom {
311311
m.selectedItemIdx = max(0, len(m.allItems)-1)
312+
m.scrollSoSelectionInView()
312313
} else if m.maintainSelection {
313314
// TODO: could flag when content is sorted & comparable and use binary search instead
314315
found := false
@@ -323,10 +324,14 @@ func (m *Model[T]) SetContent(content []T) {
323324
m.selectedItemIdx = 0
324325
}
325326
}
326-
m.selectedItemIdx = clampValMinMax(m.selectedItemIdx, 0, len(m.allItems)-1)
327-
m.scrollSoSelectionInView()
328-
if inView := m.selectionInViewInfo(); inView.numLinesSelectionInView > 0 {
329-
m.scrollUp(initialNumLinesAboveSelection - inView.numLinesAboveSelection)
327+
328+
// when staying at bottom, just want to scroll so selection in view, which is done above
329+
if !stayAtBottom {
330+
m.selectedItemIdx = clampValMinMax(m.selectedItemIdx, 0, len(m.allItems)-1)
331+
m.scrollSoSelectionInView()
332+
if inView := m.selectionInViewInfo(); inView.numLinesSelectionInView > 0 {
333+
m.scrollUp(initialNumLinesAboveSelection - inView.numLinesAboveSelection)
334+
}
330335
}
331336
}
332337
}

0 commit comments

Comments
 (0)