Skip to content

Commit c8771c0

Browse files
authored
show a token for current line (#93)
1 parent 50d7a3e commit c8771c0

File tree

2 files changed

+226
-221
lines changed

2 files changed

+226
-221
lines changed

src/printing.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function print_sourcecode(io::IO, code::String, line::Integer, defline::Integer)
202202
startline = compute_line(file, startoffset)
203203
stopline = compute_line(file, stopoffset)
204204
current_line = line
205-
stoplinelength = length(string(stopline))
205+
stoplinelength = ndigits(stopline)
206206

207207
code = split(code[(startoffset+1):(stopoffset+1)],'\n')
208208
lineno = startline
@@ -225,9 +225,14 @@ function print_sourcecode(io::IO, code::String, line::Integer, defline::Integer)
225225
code[i] = code[i][min_indentation+1:end]
226226
end
227227

228+
stoplinelength += stoplinelength == ndigits(current_line)
228229
for textline in code
230+
prefix = lineno == current_line ? ">" :
231+
ndigits(lineno) > ndigits(current_line) ?
232+
"" :
233+
" "
229234
printstyled(io,
230-
string(lpad(lineno, stoplinelength), " ");
235+
string(lpad(string(prefix, lineno), stoplinelength , " "), " "),
231236
color = lineno == current_line ? :yellow : :bold)
232237
println(io, textline)
233238
lineno += 1

0 commit comments

Comments
 (0)