aboutsummaryrefslogtreecommitdiff
path: root/ccwl
diff options
context:
space:
mode:
authorArun Isaac2023-11-06 15:39:06 +0000
committerArun Isaac2023-11-06 15:39:06 +0000
commit458011fbb95610d1afbcc077df938213e7426582 (patch)
treea22d5858074a93a433fad037ca66f50b5de88849 /ccwl
parent575410631f6ad4670c0fef1cff668887637c0de8 (diff)
downloadccwl-458011fbb95610d1afbcc077df938213e7426582.tar.gz
ccwl-458011fbb95610d1afbcc077df938213e7426582.tar.lz
ccwl-458011fbb95610d1afbcc077df938213e7426582.zip
ui: Do not attempt to display the line preceding the 0th.
* ccwl/ui.scm (source-in-context): Do not attempt to display the line preceding the 0th. * tests/ui.scm ("display source in context on 0th line"): New line.
Diffstat (limited to 'ccwl')
-rw-r--r--ccwl/ui.scm18
1 files changed, 10 insertions, 8 deletions
diff --git a/ccwl/ui.scm b/ccwl/ui.scm
index c499041..7f5c76a 100644
--- a/ccwl/ui.scm
+++ b/ccwl/ui.scm
@@ -124,14 +124,16 @@ with S-expression at LINE-NUMBER, COLUMN-NUMBER highlit in
red. LINE-NUMBER and COLUMN-NUMBER are zero-based."
(call-with-output-string
(lambda (out)
- ;; Get to line preceding syntax x.
- (repeat (cut get-line port)
- (max 0 (1- line-number)))
- ;; Display line preceding syntax x unless blank.
- (let ((line (get-line port)))
- (unless (or (zero? line-number)
- (string-blank? line))
- (put-line line out)))
+ ;; Unless the 0th line is requested, display line preceding
+ ;; syntax x.
+ (unless (zero? line-number)
+ ;; Get to line preceding syntax x.
+ (repeat (cut get-line port)
+ (1- line-number))
+ ;; Display line preceding syntax x unless blank.
+ (let ((line (get-line port)))
+ (unless (string-blank? line)
+ (put-line line out))))
;; Display part of line before syntax x.
(display (get-string-n port column-number)
out)