test(language-service): Remove all markers from test project (#37475)
This commit removes all markers from the inline template in `AppComponent` and external template in `TemplateReference`. Test scenarios should be colocated with the test cases themselves. Besides, many existing cases are invalid. For example, if we want to test autocomplete for HTML element, the existing test case is like: ``` <~{cursor} h1> ``` This doesn't make much sense, becasue the language service already sees the `h1` tag in the template. The correct test case should be: ``` <~{cursor ``` IMO, this reflects the real-world use case better. This commit also uncovers a bug in the way HTML entities autocompletion is done. There's an off-by-one error in which a cursor that immediately trails the ampersand character fails to trigger HTML entities autocompletion. PR Close #37475
This commit is contained in:
@ -361,12 +361,18 @@ function elementCompletions(info: ng.AstResult): ng.CompletionEntry[] {
|
||||
|
||||
function entityCompletions(value: string, position: number): ng.CompletionEntry[] {
|
||||
// Look for entity completions
|
||||
// TODO(kyliau): revisit the usefulness of this feature. It provides
|
||||
// autocompletion for HTML entities, which IMO is outside the core functionality
|
||||
// of Angular language service. Besides, we do not have a complete list.
|
||||
// See https://dev.w3.org/html5/html-author/charref
|
||||
const re = /&[A-Za-z]*;?(?!\d)/g;
|
||||
let found: RegExpExecArray|null;
|
||||
let result: ng.CompletionEntry[] = [];
|
||||
while (found = re.exec(value)) {
|
||||
let len = found[0].length;
|
||||
if (position >= found.index && position < (found.index + len)) {
|
||||
// end position must be inclusive to account for cases like '&|' where
|
||||
// cursor is right behind the ampersand.
|
||||
if (position >= found.index && position <= (found.index + len)) {
|
||||
result = Object.keys(NAMED_ENTITIES).map(name => {
|
||||
return {
|
||||
name: `&${name};`,
|
||||
|
Reference in New Issue
Block a user