Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit ac7d6c3

Browse files
committed
Merge pull request #4805 from TomMalbran/tom/open-line-fix
Fixes the Open Line tests when the indentation is set as tabs in the main window
2 parents 27dbf97 + b86570a commit ac7d6c3

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

test/spec/EditorCommandHandlers-test.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,14 +2412,16 @@ define(function (require, exports, module) {
24122412
});
24132413

24142414
describe("Open Line Above and Below", function () {
2415-
var indentUnit = Editor.getSpaceUnits();
2416-
2417-
var indentation = (function () {
2418-
// generate indent string once
2419-
var spaces = [];
2420-
spaces.length = indentUnit + 1;
2421-
return spaces.join(" ");
2422-
}());
2415+
var indentUnit = SpecRunnerUtils.EDITOR_USE_TABS ? 1 : SpecRunnerUtils.EDITOR_SPACE_UNITS,
2416+
indentation = (function () {
2417+
// generate indent string once
2418+
if (SpecRunnerUtils.EDITOR_USE_TABS) {
2419+
return "\t";
2420+
}
2421+
var spaces = [];
2422+
spaces.length = indentUnit + 1;
2423+
return spaces.join(" ");
2424+
}());
24232425

24242426
beforeEach(setupFullEditor);
24252427

@@ -2514,11 +2516,11 @@ define(function (require, exports, module) {
25142516
CommandManager.execute(Commands.EDIT_OPEN_LINE_ABOVE, myEditor);
25152517

25162518
var lines = defaultContent.split("\n");
2517-
lines.splice(2, 0, " " + indentation);
2519+
lines.splice(2, 0, indentation + indentation);
25182520
var expectedText = lines.join("\n");
25192521

25202522
expect(myDocument.getText()).toEqual(expectedText);
2521-
expectCursorAt({line: 2, ch: 4 + indentUnit});
2523+
expectCursorAt({line: 2, ch: indentUnit * 2});
25222524
});
25232525

25242526
it("should insert new line below when no selection", function () {
@@ -2598,11 +2600,11 @@ define(function (require, exports, module) {
25982600
CommandManager.execute(Commands.EDIT_OPEN_LINE_BELOW, myEditor);
25992601

26002602
var lines = defaultContent.split("\n");
2601-
lines.splice(3, 0, " " + indentation);
2603+
lines.splice(3, 0, indentation + indentation);
26022604
var expectedText = lines.join("\n");
26032605

26042606
expect(myDocument.getText()).toEqual(expectedText);
2605-
expectCursorAt({line: 3, ch: 4 + indentUnit});
2607+
expectCursorAt({line: 3, ch: indentUnit * 2});
26062608
});
26072609

26082610
it("should insert new line below when multiple line selection", function () {
@@ -2612,11 +2614,11 @@ define(function (require, exports, module) {
26122614
CommandManager.execute(Commands.EDIT_OPEN_LINE_BELOW, myEditor);
26132615

26142616
var lines = defaultContent.split("\n");
2615-
lines.splice(5, 0, " " + indentation);
2617+
lines.splice(5, 0, indentation + indentation);
26162618
var expectedText = lines.join("\n");
26172619

26182620
expect(myDocument.getText()).toEqual(expectedText);
2619-
expectCursorAt({line: 5, ch: 4 + indentUnit});
2621+
expectCursorAt({line: 5, ch: indentUnit * 2});
26202622
});
26212623
});
26222624

test/spec/SpecRunnerUtils.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ define(function (require, exports, module) {
4040
LanguageManager = require("language/LanguageManager");
4141

4242
var TEST_PREFERENCES_KEY = "com.adobe.brackets.test.preferences",
43+
EDITOR_USE_TABS = false,
44+
EDITOR_SPACE_UNITS = 4,
4345
OPEN_TAG = "{{",
4446
CLOSE_TAG = "}}",
4547
RE_MARKER = /\{\{(\d+)\}\}/g,
@@ -262,6 +264,8 @@ define(function (require, exports, module) {
262264

263265
// create Editor instance
264266
var editor = new Editor(doc, true, $editorHolder.get(0), visibleRange);
267+
Editor.setUseTabChar(EDITOR_USE_TABS);
268+
Editor.setSpaceUnits(EDITOR_SPACE_UNITS);
265269
EditorManager._notifyActiveEditorChanged(editor);
266270

267271
return editor;
@@ -1120,8 +1124,10 @@ define(function (require, exports, module) {
11201124
});
11211125
});
11221126

1123-
exports.TEST_PREFERENCES_KEY = TEST_PREFERENCES_KEY;
1124-
1127+
exports.TEST_PREFERENCES_KEY = TEST_PREFERENCES_KEY;
1128+
exports.EDITOR_USE_TABS = EDITOR_USE_TABS;
1129+
exports.EDITOR_SPACE_UNITS = EDITOR_SPACE_UNITS;
1130+
11251131
exports.chmod = chmod;
11261132
exports.remove = remove;
11271133
exports.getTestRoot = getTestRoot;

0 commit comments

Comments
 (0)