Skip to content

Commit

Permalink
fix: get text
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Nov 7, 2023
1 parent 19d7bc1 commit d4dd8d1
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lib/get-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -223,7 +222,10 @@ export default class GetText {

if ( template ) {
this.#parseEjs( template, {
"start": arg.loc.start,
"start": {
...arg.loc.start,
"force": true,
},
} );
}

Expand Down Expand Up @@ -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 };
}
Expand Down

0 comments on commit d4dd8d1

Please sign in to comment.