From d4dd8d13cf55d0724c47b3653dfaf6e7c4771999 Mon Sep 17 00:00:00 2001 From: zdm Date: Tue, 7 Nov 2023 20:08:15 +0200 Subject: [PATCH] fix: get text --- lib/get-text.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/get-text.js b/lib/get-text.js index c7db2d72..b75e9f04 100644 --- a/lib/get-text.js +++ b/lib/get-text.js @@ -162,7 +162,6 @@ export default class GetText { yaml.parse( content, { "all": true, locale, ejs } ); } - // XXX node / location #parseEjs ( content, { start } = {} ) { const template = new Template( content ); @@ -223,7 +222,10 @@ export default class GetText { if ( template ) { this.#parseEjs( template, { - "start": arg.loc.start, + "start": { + ...arg.loc.start, + "force": true, + }, } ); } @@ -349,17 +351,20 @@ export default class GetText { } #getNodeLocation ( node, { start } = {} ) { - const nodeStart = node.loc.start; - - var line = nodeStart.line, - column = nodeStart.column; + var { line, column } = node.loc.start; if ( start ) { - if ( line === 1 ) column += start.column; - line += start.line - 1; - } + if ( start.force ) { + ( { line, column } = start ); + } + else { + if ( line === 1 ) { + column += start.column; + } - // message = `Error at ${loc.line}:${loc.column} in the file: ${this.#relativePath}\n` + message; + line += start.line - 1; + } + } return { line, column }; }