Skip to content

Commit a089d09

Browse files
committed
fix: integ tests for auto tab spacing detection
1 parent cdb3f6c commit a089d09

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/editor/EditorHelper/EditorPreferences.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ define(function (require, exports, module) {
6262
AUTO_TAB_SIZE = 4,
6363
MAX_SPACE_UNITS = 10,
6464
MAX_TAB_SIZE = 10,
65-
MAX_AUTO_TAB_UNITS = 3;
65+
MAX_AUTO_TAB_UNITS = 4;
6666

6767
const LINE_NUMBER_GUTTER = "CodeMirror-linenumbers",
6868
LINE_NUMBER_GUTTER_PRIORITY = 100,

test/spec/spacing-auto-detect-integ-test.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,26 @@ define(function (require, exports, module) {
7373
await __PR.closeFile();
7474
});
7575

76+
async function verifyIf2TabsWithEdits() {
77+
__PR.setCursors(["1:14"]);
78+
__PR.keydown(["RETURN"]);
79+
__PR.expectCursorsToBe(["2:3"]);
80+
await __PR.undo();
81+
}
82+
7683
it(`should detect 2 tabs auto`, async function () {
7784
await __PR.openFile("tab-2.js");
78-
validateSpacing("Tab Size:", "2", "Auto");
85+
validateSpacing("Tab Size:", "4", "Auto"); // auto mode will always fix tab space to 4
86+
await verifyIf2TabsWithEdits();
7987
await __PR.closeFile();
8088
});
8189

82-
it(`should detect 12 tabs as 10 tabs auto`, async function () {
90+
it(`should detect 12 tabs as 4 tab units only`, async function () {
8391
await __PR.openFile("tab-12.js");
84-
validateSpacing("Tab Size:", "10", "Auto");
92+
validateSpacing("Tab Size:", "4", "Auto");
93+
__PR.setCursors(["1:14"]);
94+
__PR.keydown(["RETURN"]);
95+
__PR.expectCursorsToBe(["2:5"]);
8596
await __PR.closeFile();
8697
});
8798

@@ -92,7 +103,8 @@ define(function (require, exports, module) {
92103
validateSpacing("Tab Size:", "4", "Auto");
93104
// now switch to another file
94105
await __PR.openFile("tab-2.js");
95-
validateSpacing("Tab Size:", "2", "Auto");
106+
validateSpacing("Tab Size:", "4", "Auto");
107+
await verifyIf2TabsWithEdits();
96108
// now switch back and it should remember the overridden settings
97109
await __PR.openFile("space-1.js");
98110
validateSpacing("Tab Size:", "4", "Auto");
@@ -102,7 +114,8 @@ define(function (require, exports, module) {
102114
// now close the file and switch to another file
103115
await __PR.closeFile();
104116
await __PR.openFile("tab-2.js");
105-
validateSpacing("Tab Size:", "2", "Auto");
117+
validateSpacing("Tab Size:", "4", "Auto");
118+
await verifyIf2TabsWithEdits();
106119
// now switch back and it should remember the overridden settings
107120
await __PR.openFile("space-1.js");
108121
validateSpacing("Tab Size:", "6", "Auto");
@@ -111,7 +124,8 @@ define(function (require, exports, module) {
111124

112125
it(`should switching to fixed mode default to 4 spaces for all files`, async function () {
113126
await __PR.openFile("tab-2.js");
114-
validateSpacing("Tab Size:", "2", "Auto");
127+
validateSpacing("Tab Size:", "4", "Auto");
128+
await verifyIf2TabsWithEdits();
115129
$("#indent-auto").click();
116130
validateSpacing("Spaces:", "4", "Fixed");
117131
await __PR.openFile("space-1.js");
@@ -131,14 +145,24 @@ define(function (require, exports, module) {
131145
await __PR.closeFile();
132146
});
133147

148+
async function verifyIf2SpacesWithEdit() {
149+
__PR.setCursors(["1:14"]);
150+
__PR.keydown(["RETURN"]);
151+
__PR.expectCursorsToBe(["2:4"]);
152+
__PR.validateText(` `, "2:1-2:4");
153+
await __PR.undo();
154+
}
155+
134156
it(`should toggling auto mode recompute the spacing`, async function () {
135157
await __PR.openFile("tab-2.js");
136158
__PR.EDITING.setEditorSpacing(false, 3, true);
137159
validateSpacing("Spaces:", "3", "Auto");
160+
await verifyIf2SpacesWithEdit();
138161
// now toggle the auto to fixed and then to auto once to force recompute spacing
139162
$("#indent-auto").click();
140163
$("#indent-auto").click();
141-
validateSpacing("Tab Size:", "2", "Auto");
164+
validateSpacing("Tab Size:", "4", "Auto");
165+
await verifyIf2TabsWithEdits();
142166
await __PR.closeFile();
143167
});
144168
});

0 commit comments

Comments
 (0)