Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit e6a1f16

Browse files
authored
fix: don't unescape text in token_positions functions (#55)
1 parent dd9dcd0 commit e6a1f16

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/token_position.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ describe('token_positions', () => {
7777
}
7878
}
7979
})
80+
81+
it('does not change the text', () => {
82+
const text = 'fmt.Sprintf("%5d", someVar)'
83+
const elem = dom.createElementFromString(text)
84+
85+
convertNode(elem)
86+
87+
expect(elem.textContent).to.equal(text)
88+
})
8089
})
8190

8291
describe('findElementWithOffset()', () => {

src/token_position.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function convertNode(parentNode: HTMLElement): void {
109109
const isLastNode = i === parentNode.childNodes.length - 1
110110

111111
if (node.nodeType === Node.TEXT_NODE) {
112-
let nodeText = unescape(node.textContent || '')
112+
let nodeText = node.textContent || ''
113113
if (nodeText === '') {
114114
continue
115115
}
@@ -160,7 +160,7 @@ const enum TokenType {
160160
* @param node The node containing the token.
161161
*/
162162
function getTokenType(node: Node): TokenType {
163-
const text = unescape(node.textContent || '')
163+
const text = node.textContent || ''
164164
if (text.length === 0) {
165165
return TokenType.Other
166166
}

0 commit comments

Comments
 (0)