From f70b3ede9d8224bb6ad54b8057d95e0b82f34c7a Mon Sep 17 00:00:00 2001 From: Philipp Arndt <2f.mail@gmx.de> Date: Sun, 22 Nov 2020 14:13:15 +0100 Subject: [PATCH] fix for org --- src/ttOrg.ts | 2 +- test/commands.test.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ttOrg.ts b/src/ttOrg.ts index 4376be0..4f68c2b 100644 --- a/src/ttOrg.ts +++ b/src/ttOrg.ts @@ -38,7 +38,7 @@ export class OrgParser implements tt.Parser { } isSeparatorRow(text: string): boolean { - return text.length > 1 && text[1] === horizontalSeparator; + return text.length > 1 && text[1] === horizontalSeparator && text.match(/^[+|-\s]+$/) ? true : false;; } } diff --git a/test/commands.test.ts b/test/commands.test.ts index 0735ae1..e4022ea 100644 --- a/test/commands.test.ts +++ b/test/commands.test.ts @@ -28,7 +28,24 @@ suite('Commands', () => { | -1 | -1 |`; await inTextEditor({language: 'markdown', content: testCase}, async (editor, document) => { - await cfg.override({mode: 'markdown'}); + await cfg.override({mode: cfg.Mode.Markdown}); + move(editor, 0, 1); + await vscode.commands.executeCommand('text-tables.gotoNextCell'); + + assert.equal(document.getText(), expected); + }); + }); + + test('Regression: Format under cursor causes loss of data (org).', async () => { + const testCase = + `|A|B| +|-1|-1|`; + const expected = + `| A | B | +| -1 | -1 |`; + + await inTextEditor({language: 'markdown', content: testCase}, async (editor, document) => { + await cfg.override({mode: cfg.Mode.Org}); move(editor, 0, 1); await vscode.commands.executeCommand('text-tables.gotoNextCell');