Expose adjustWhitespace to TextEditor API.

- Disable adjustWhitespace in text edits with snippets so that code
  actions do not adjust snippet indentation by default
- Adjust Emmet extension so that adjustWhitespace is enabled
- Add testcase

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
This commit is contained in:
Roland Grunberg
2024-11-20 12:00:55 -05:00
parent a514d865ee
commit 68c2087f8f
8 changed files with 47 additions and 8 deletions

View File

@@ -94,6 +94,37 @@ suite('vscode API - editors', () => {
});
});
/**
* Given :
* This is line 1
* |
*
* Expect :
* This is line 1
* This is line 2
* This is line 3
*
* The 3rd line should not be auto-indented, as the edit already
* contains the necessary adjustment.
*/
test('insert snippet with replacement, avoid adjusting indentation', () => {
const snippetString = new SnippetString()
.appendText('This is line 2\n This is line 3');
return withRandomFileEditor('This is line 1\n ', (editor, doc) => {
editor.selection = new Selection(
new Position(1, 3),
new Position(1, 3)
);
return editor.insertSnippet(snippetString, undefined, { undoStopAfter: false, undoStopBefore: false, adjustWhitespace: false }).then(inserted => {
assert.ok(inserted);
assert.strictEqual(doc.getText(), 'This is line 1\n This is line 2\n This is line 3');
assert.ok(doc.isDirty);
});
});
});
test('insert snippet with replacement, selection as argument', () => {
const snippetString = new SnippetString()
.appendText('has been');