From a29d8cd7d533f3a9365d477f3dec4557b4603647 Mon Sep 17 00:00:00 2001 From: Isaac Snow Date: Thu, 6 Sep 2018 10:20:26 -0700 Subject: [PATCH 1/2] chore: add test case --- src/token_position.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/token_position.test.ts b/src/token_position.test.ts index c5039f40..c1560a90 100644 --- a/src/token_position.test.ts +++ b/src/token_position.test.ts @@ -77,6 +77,15 @@ describe('token_positions', () => { } } }) + + it.only('does not change the text', () => { + const text = 'fmt.Sprintf("%5d", someVar)' + const elem = dom.createElementFromString(text) + + convertNode(elem) + + expect(elem.textContent).to.equal(text) + }) }) describe('findElementWithOffset()', () => { From 314399ea628355c97e3fc7e676946603f6e525ed Mon Sep 17 00:00:00 2001 From: Isaac Snow Date: Thu, 6 Sep 2018 10:55:24 -0700 Subject: [PATCH 2/2] fix: don't unescape text in token_positions functions --- src/token_position.test.ts | 2 +- src/token_position.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/token_position.test.ts b/src/token_position.test.ts index c1560a90..2a911b8f 100644 --- a/src/token_position.test.ts +++ b/src/token_position.test.ts @@ -78,7 +78,7 @@ describe('token_positions', () => { } }) - it.only('does not change the text', () => { + it('does not change the text', () => { const text = 'fmt.Sprintf("%5d", someVar)' const elem = dom.createElementFromString(text) diff --git a/src/token_position.ts b/src/token_position.ts index aa544a61..e34379aa 100644 --- a/src/token_position.ts +++ b/src/token_position.ts @@ -109,7 +109,7 @@ export function convertNode(parentNode: HTMLElement): void { const isLastNode = i === parentNode.childNodes.length - 1 if (node.nodeType === Node.TEXT_NODE) { - let nodeText = unescape(node.textContent || '') + let nodeText = node.textContent || '' if (nodeText === '') { continue } @@ -160,7 +160,7 @@ const enum TokenType { * @param node The node containing the token. */ function getTokenType(node: Node): TokenType { - const text = unescape(node.textContent || '') + const text = node.textContent || '' if (text.length === 0) { return TokenType.Other }