Trim range when formatting so that it excludes leading/trailing spaces

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2020-09-29 14:15:20 +01:00
parent 7fa1214cf1
commit ffa7ceb70e
3 changed files with 29 additions and 4 deletions

View file

@ -88,4 +88,19 @@ describe('editor/range', function() {
expect(model.parts[1].text).toBe("man");
expect(model.parts.length).toBe(2);
});
it('range trim spaces off both ends', () => {
const renderer = createRenderer();
const pc = createPartCreator();
const model = new EditorModel([
pc.plain("abc abc abc"),
], pc, renderer);
const range = model.startRange(
model.positionForOffset(3, false), // at end of first `abc`
model.positionForOffset(8, false), // at start of last `abc`
);
expect(range.parts[0].text).toBe(" abc ");
range.trim();
expect(range.parts[0].text).toBe("abc");
});
});