Skip to content

Commit

Permalink
Fix handling of \r\n line terminators in Markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
valentjn committed Jan 16, 2021
1 parent 71e2a6c commit e0b6fa6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Add support for Markdown tables as in [GitHub Flavored Markdown](https://github.github.com/gfm/#tables-extension-)
- Enable `Add to dictionary` quick fix for Slovak rule IDs `MUZSKY_ROD_NEZIV_A`, `ZENSKY_ROD_A`, and `STREDNY_ROD_A` (fixes [vscode-ltex#221](https://github.com/valentjn/vscode-ltex/issues/221))
- Remove superfluous spaces in messages of diagnostics
- Fix handling of `\r\n` (Windows) line terminators in Markdown
- Use Flexmark's YAML Front Matter extension to ignore YAML front matter in Markdown instead of own handling
- Print Flexmark AST of Markdown documents to log when [`ltex.ltex-ls.logLevel`](https://valentjn.github.io/vscode-ltex/docs/settings.html#ltexltex-lsloglevel) is `"finest"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ private void addMarkup(int newPos) {

while (true) {
if ((this.pos >= this.code.length()) || (this.pos >= newPos)) break;
int curPos = this.code.indexOf('\r', this.pos);
int curPos = this.code.indexOf("\r\n", this.pos);
if (curPos != -1) curPos += 1;

if ((curPos == -1) || (curPos >= newPos)) {
curPos = this.code.indexOf('\n', this.pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public void test() throws IOException {
+ "Paragraph with\n"
+ "multiple lines and [link](example.com)\n",
"Heading\nParagraph with multiple lines and link\n");
assertPlainText(
"This is a \r\ntest.\r\n",
"This is a test.\n");
assertPlainText(
"# This is a © Test\n"
+ "Another [day – another](example.com) sentence\n",
Expand Down

0 comments on commit e0b6fa6

Please sign in to comment.