fix(language-service): CRLF offset in inline template (#34737)

This commit fixes incorrect CRLF offsets in inline template.

PR closes https://github.com/angular/vscode-ng-language-service/issues/520

PR Close #34737
This commit is contained in:
Keen Yee Liau
2020-01-10 17:22:59 -08:00
committed by atscott
parent 6d534f10e6
commit bfe9bc912a
2 changed files with 22 additions and 6 deletions

View File

@ -98,7 +98,9 @@ export class InlineTemplate extends BaseTemplate {
throw new Error(`Inline template and component class should belong to the same source file`);
}
this.fileName = sourceFile.fileName;
this.source = templateNode.text;
// node.text returns the TS internal representation of the normalized text,
// and all CR characters are stripped. node.getText() returns the raw text.
this.source = templateNode.getText().slice(1, -1); // strip leading and trailing quotes
this.span = {
// TS string literal includes surrounding quotes in the start/end offsets.
start: templateNode.getStart() + 1,