fix(@angular-devkit/schematics): fix generate
mangling files contai…
#11978
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…ning wide characters
Executing a command like
ng generate component my-component
can sometimes lead to mangled Angular module files when inserting the component intodeclaration
and adding the import.This happens if the file contains characters that are wider than one byte e.g. a copyright sign or an umlaut. Today it is expected to be able to use two byte long characters in code.
The
UpdateBuffer
class operates using Buffer objects which use byte arrays internally. Using text node positions provided by the TypeScript library, these will not match up.This change looks up the textual position inside the Buffer and uses the correct index.
Closes #7732
Closes #7851
Closes #7950
Closes #9560
Closes #10030
Closes #10095