Skip to content

Commit 3d84abb

Browse files
authored
Merge pull request microsoft#208303 from microsoft/sensitive-falcon
Adding a test in the auto-indentation test suite
2 parents e675692 + 820438f commit 3d84abb

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

src/vs/editor/contrib/indentation/test/browser/indentation.test.ts

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
732732
// issue: Should indent after an equal sign is detected followed by whitespace characters.
733733
// This should be outdented when a semi-colon is detected indicating the end of the assignment.
734734

735+
// TODO: requires exploring indent/outdent pairs instead
736+
735737
const model = createTextModel([
736738
'const array ='
737739
].join('\n'), languageId, {});
@@ -753,6 +755,8 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
753755
// https://github.com/microsoft/vscode/issues/43244
754756
// issue: When a dot is written, we should detect that this is a method call and indent accordingly
755757

758+
// TODO: requires exploring indent/outdent pairs instead
759+
756760
const model = createTextModel([
757761
'const array = [1, 2, 3];',
758762
'array.'
@@ -776,6 +780,8 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
776780
// https://github.com/microsoft/vscode/issues/43244
777781
// issue: When a dot is written, we should detect that this is a method call and indent accordingly
778782

783+
// TODO: requires exploring indent/outdent pairs instead
784+
779785
const model = createTextModel([
780786
'const array = [1, 2, 3]',
781787
].join('\n'), languageId, {});
@@ -798,6 +804,8 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
798804
// https://github.com/microsoft/vscode/issues/43244
799805
// Currently passes, but should pass with all the tests above too
800806

807+
// TODO: requires exploring indent/outdent pairs instead
808+
801809
const model = createTextModel([
802810
'const array = [1, 2, 3]',
803811
' .filter(() => true)'
@@ -816,10 +824,38 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
816824
});
817825
});
818826

827+
test.skip('issue #43244: keep indentation when chained methods called on object/array', () => {
828+
829+
// https://github.com/microsoft/vscode/issues/43244
830+
// When the call chain is not finished yet, and we type a dot, we do not want to change the indentation
831+
832+
// TODO: requires exploring indent/outdent pairs instead
833+
834+
const model = createTextModel([
835+
'const array = [1, 2, 3]',
836+
' .filter(() => true)',
837+
' '
838+
].join('\n'), languageId, {});
839+
disposables.add(model);
840+
841+
withTestCodeEditor(model, { autoIndent: "full" }, (editor, viewModel, instantiationService) => {
842+
registerLanguage(instantiationService, languageId, Language.TypeScript, disposables);
843+
editor.setSelection(new Selection(3, 5, 3, 5));
844+
viewModel.type(".");
845+
assert.strictEqual(model.getValue(), [
846+
'const array = [1, 2, 3]',
847+
' .filter(() => true)',
848+
' .' // here we don't want to increase the indentation because we have chained methods
849+
].join('\n'));
850+
});
851+
});
852+
819853
test.skip('issue #43244: outdent when a semi-color is detected indicating the end of the assignment', () => {
820854

821855
// https://github.com/microsoft/vscode/issues/43244
822856

857+
// TODO: requires exploring indent/outdent pairs instead
858+
823859
const model = createTextModel([
824860
'const array = [1, 2, 3]',
825861
' .filter(() => true);'
@@ -844,17 +880,17 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
844880

845881
const model = createTextModel([
846882
'const array = [1, 2, 3, 4, 5];',
847-
'array.map(v =>)'
883+
'array.map(_)'
848884
].join('\n'), languageId, {});
849885
disposables.add(model);
850886

851887
withTestCodeEditor(model, { autoIndent: "full" }, (editor, viewModel, instantiationService) => {
852888
registerLanguage(instantiationService, languageId, Language.TypeScript, disposables);
853-
editor.setSelection(new Selection(2, 15, 2, 15));
889+
editor.setSelection(new Selection(2, 12, 2, 12));
854890
viewModel.type("\n", 'keyboard');
855891
assert.strictEqual(model.getValue(), [
856892
'const array = [1, 2, 3, 4, 5];',
857-
'array.map(v =>',
893+
'array.map(_',
858894
' ',
859895
')'
860896
].join('\n'));

src/vs/workbench/contrib/codeEditor/test/node/autoindent.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ suite('Auto-Reindentation - TypeScript/JavaScript', () => {
190190
// explanation: if (, [, {, is followed by a forward slash then assume we are in a regex pattern, and do not indent
191191

192192
// increaseIndentPattern: /^((?!\/\/).)*(\{([^}"'`]*|(\t|[ ])*\/\/.*)|\([^)"'`]*|\[[^\]"'`]*)$/ -> /^((?!\/\/).)*(\{([^}"'`/]*|(\t|[ ])*\/\/.*)|\([^)"'`/]*|\[[^\]"'`/]*)$/
193-
// -> Final current increase indent pattern
193+
// -> Final current increase indent pattern at of writing
194194

195195
const fileContents = [
196196
'const r = /{/;',
@@ -214,7 +214,7 @@ suite('Auto-Reindentation - TypeScript/JavaScript', () => {
214214
// fix: https://github.com/microsoft/vscode/commit/7910b3d7bab8a721aae98dc05af0b5e1ea9d9782
215215

216216
// decreaseIndentPattern: /^(.*\*\/)?\s*[\}\]\)].*$/ -> /^((?!.*?\/\*).*\*\/)?\s*[\}\]\)].*$/
217-
// -> Final current decrease indent pattern
217+
// -> Final current decrease indent pattern at the time of writing
218218

219219
// explanation: Positive lookahead: (?= «pattern») matches if pattern matches what comes after the current location in the input string.
220220
// Negative lookahead: (?! «pattern») matches if pattern does not match what comes after the current location in the input string
@@ -282,10 +282,8 @@ suite('Auto-Reindentation - TypeScript/JavaScript', () => {
282282
// related: https://github.com/microsoft/vscode/issues/43244
283283
// explanation: When you have an arrow function, you don't have { or }, but you would expect indentation to still be done in that way
284284

285-
/*
286-
Notes: Currently the reindent edit operations does not call the onEnter rules
287-
The reindent should also call the onEnter rules to get the correct indentation
288-
*/
285+
// TODO: requires exploring indent/outdent pairs instead
286+
289287
const fileContents = [
290288
'const add1 = (n) =>',
291289
' n + 1;',

0 commit comments

Comments
 (0)