Skip to content

Commit a0b824f

Browse files
committed
getline()
1 parent 4681899 commit a0b824f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/vimscript/expression/evaluate.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { escapeRegExp, isInteger } from 'lodash';
3535
import { VimState } from '../../state/vimState';
3636
import { Position } from 'vscode';
3737
import { Mode } from '../../mode/mode';
38+
import { Range } from 'vscode';
3839

3940
// ID of next lambda; incremented each time one is created
4041
let lambdaNumber = 1;
@@ -1080,7 +1081,18 @@ export class EvaluationContext {
10801081
const curswant = this.vimState!.desiredColumn + 1;
10811082
return list([int(bufnum), int(lnum), int(col), int(off), int(curswant)]);
10821083
}
1083-
// TODO: getline()
1084+
case 'getline': {
1085+
const [lnum, _end] = getArgs(1, 2);
1086+
// TODO: When {lnum} is a String that doesn't start with a digit, line() is called
1087+
if (_end === undefined) {
1088+
return str(this.vimState!.document.lineAt(toInt(lnum!)).text);
1089+
}
1090+
const lines: string[] = [];
1091+
for (let i = toInt(lnum!); i <= toInt(_end); i++) {
1092+
lines.push(this.vimState!.document.lineAt(i).text);
1093+
}
1094+
return list(lines.map(str));
1095+
}
10841096
case 'getpos': {
10851097
const [s] = getArgs(1);
10861098
const { bufnum, lnum, col, off } = getpos(toString(s!));

0 commit comments

Comments
 (0)