Skip to content

UpdateRecorder should support multiple adjacent inserts #21110

@dgp1130

Description

@dgp1130

🐞 Bug report

Command (mark with an x)

  • schematics

Is this a regression?

No

Description

From #20190.

UpdateRecorder doesn't support multiple adjacent inserts.

🔬 Minimal Reproduction

it('works with multiple adjacent inserts', () => {
  const buffer = Buffer.from('Hello beautiful World');
  const entry = new SimpleFileEntry(normalize('/some/path'), buffer);

  const recorder = new UpdateRecorderBase(entry);
  recorder.remove(6, 9);
  recorder.insertRight(6, 'amazing');
  recorder.insertRight(15, ' and fantastic');
  const result = recorder.apply(buffer);
  expect(result.toString()).toBe('Hello amazing and fantastic World');
});

Anything else relevant?

Best workaround is probably to use something more comprehensive like magic-string, but that probably shouldn't be required for something this simple.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions