mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-24 17:33:32 +01:00
Stem my patholigical tendency to use iterators wherever possible (but not my pathological desire to clean up perfectly servicable code).
This commit is contained in:
@@ -362,32 +362,24 @@ lookup:
|
|||||||
|
|
||||||
this.readHeredoc = function (end) {
|
this.readHeredoc = function (end) {
|
||||||
let res = [];
|
let res = [];
|
||||||
try {
|
io.sourcing.line++;
|
||||||
io.sourcing.line++;
|
while (++i < lines.length) {
|
||||||
while (true)
|
if (lines[i] === end)
|
||||||
let ([i, line] = iter.next()) {
|
return res.join("\n");
|
||||||
if (line === end)
|
res.push(lines[i]);
|
||||||
return res.join("\n");
|
|
||||||
res.push(line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e if e instanceof StopIteration) {}
|
|
||||||
dactyl.assert(false, "Unexpected end of file waiting for " + end);
|
dactyl.assert(false, "Unexpected end of file waiting for " + end);
|
||||||
};
|
};
|
||||||
|
|
||||||
let iter = Iterator(lines);
|
for (var i = 0; i < lines.length && !this.sourcing.finished; i++) {
|
||||||
for (let [i, line] in iter) {
|
// Deal with editors from Silly OSs.
|
||||||
if (this.sourcing.finished)
|
let line = lines[i].replace(/\r$/, "");
|
||||||
break;
|
|
||||||
|
|
||||||
this.sourcing.line = i + 1;
|
this.sourcing.line = i + 1;
|
||||||
|
|
||||||
// Deal with editors from Silly OSs.
|
|
||||||
line = line.replace(/\r$/, "");
|
|
||||||
|
|
||||||
// Process escaped new lines
|
// Process escaped new lines
|
||||||
for (; i < lines.length && /^\s*\\/.test(lines[i + 1]); i++)
|
while (i < lines.length && /^\s*\\/.test(lines[i + 1]))
|
||||||
line += "\n" + iter.next()[1].replace(/^\s*\\/, "");
|
line += "\n" + lines[++i].replace(/^\s*\\/, "");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dactyl.execute(line, { setFrom: file });
|
dactyl.execute(line, { setFrom: file });
|
||||||
|
|||||||
Reference in New Issue
Block a user