Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Support autofix at the very start of blocks #119

Merged
merged 1 commit into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ function adjustBlock(block) {
// then going back one.
let i = 1;

while (i < block.rangeMap.length && block.rangeMap[i].js < range) {
while (i < block.rangeMap.length && block.rangeMap[i].js <= range) {
i++;
}

Expand Down
21 changes: 21 additions & 0 deletions tests/lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,27 @@ describe("plugin", () => {
assert.strictEqual(actual, expected);
});

it("at the very start of a block", () => {
const input = [
"This is Markdown.",
"",
"```js",
"'use strict'",
"```"
].join("\n");
const expected = [
"This is Markdown.",
"",
"```js",
"\"use strict\"",
"```"
].join("\n");
const report = cli.executeOnText(input, "test.md");
const actual = report.results[0].output;

assert.strictEqual(actual, expected);
});

it("in blocks with uncommon tags", () => {
const input = [
"This is Markdown.",
Expand Down