Skip to content

Commit 7395c15

Browse files
committed
fix: line source now shows line numbers with padding
1 parent 7290879 commit 7395c15

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

builtin/source/line.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ export function line(options: LineOptions = {}): Source<Detail> {
5858
let line = 1;
5959
let id = 0;
6060

61+
const ncols = bufinfo
62+
.linecount
63+
.toString()
64+
.length;
65+
6166
// Loop through the buffer lines in chunks.
6267
while (line <= bufinfo.linecount) {
6368
const content = await fn.getbufline(
@@ -70,9 +75,12 @@ export function line(options: LineOptions = {}): Source<Detail> {
7075

7176
let offset = 0;
7277
for (const value of content) {
78+
const lnumcol = (line + offset)
79+
.toString()
80+
.padStart(ncols, " ");
7381
yield {
7482
id: id++,
75-
value,
83+
value: `${lnumcol} ${value}`,
7684
detail: {
7785
line: line + offset,
7886
bufnr: bufinfo.bufnr,

0 commit comments

Comments
 (0)