do not reset document settings when editor setting changes

pull/468/merge
nightwing 2017-12-19 23:27:13 +04:00
rodzic 06c9006297
commit 25f191a031
2 zmienionych plików z 29 dodań i 21 usunięć

Wyświetl plik

@ -488,8 +488,11 @@ define(function(require, exports, module) {
function updateSettings(e, list, prefix) { function updateSettings(e, list, prefix) {
var options = {}; var options = {};
(list || aceSettings).forEach(function(setting) { (list || aceSettings).forEach(function(setting) {
options[setting[0]] var value = settings[setting[2]](prefix + "/ace/@" + setting[0]);
= settings[setting[2]](prefix + "/ace/@" + setting[0]); var name = setting[0];
lastSettings[name] = value;
if (!docLut[name])
options[name] = value;
}); });
handleEmit("settingsUpdate", { handleEmit("settingsUpdate", {
@ -498,8 +501,6 @@ define(function(require, exports, module) {
if (options.theme) if (options.theme)
setTheme(options.theme); setTheme(options.theme);
util.extend(lastSettings, options);
} }
settings.setDefaults("user/ace", userSettings); settings.setDefaults("user/ace", userSettings);

Wyświetl plik

@ -12,8 +12,6 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
startdate: new Date(), startdate: new Date(),
debug: true, debug: true,
hosted: true, hosted: true,
local: false,
davPrefix: "/"
}, },
"plugins/c9.core/ext", "plugins/c9.core/ext",
@ -58,16 +56,17 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
"plugins/c9.ide.dialog.common/alert_internal", "plugins/c9.ide.dialog.common/alert_internal",
{ {
consumes: ["tabManager", "ace", "commands"], consumes: ["tabManager", "ace", "commands", "settings"],
provides: [], provides: [],
setup: main setup: main
} }
], architect); ], architect);
function main(options, imports, register) { function main(options, imports, register) {
var settings = imports.settings;
var commands = imports.commands;
var tabs = imports.tabManager; var tabs = imports.tabManager;
var ace = imports.ace; var ace = imports.ace;
var commands = imports.commands;
function getTabHtml(tab) { function getTabHtml(tab) {
return tab.pane.aml.getPage("editor::" + tab.editorType).$ext; return tab.pane.aml.getPage("editor::" + tab.editorType).$ext;
@ -231,19 +230,20 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
}); });
it('should change a theme', function(done) { it('should change a theme', function(done) {
var theme = "ace/theme/textmate"; function checkTheme(id, className, callback) {
editor.ace.renderer.on("themeLoaded", function me(e) { editor.ace.renderer.on("themeLoaded", function me(e) {
if (e.theme.cssClass != "ace-tm") return; if (e.theme.cssClass != className) return;
editor.ace.renderer.removeListener("themeLoaded", me);
editor.ace.renderer.removeListener("themeLoaded", me); expect.html(getTabHtml(tabs.focussedTab).childNodes[1]).className(className);
expect.html(getTabHtml(tabs.focussedTab).childNodes[1]).className("ace-tm"); callback();
});
ace.once("themeChange", function() { ace.setTheme(id);
}
checkTheme("ace/theme/textmate", "ace-tm", function() {
checkTheme("ace/theme/tomorrow_night_bright", "ace-tomorrow-night-bright", function() {
done(); done();
}); });
ace.setTheme("ace/theme/tomorrow_night_bright");
}); });
ace.setTheme(theme);
}); });
it('should allow setting useWrapMode', function(done) { it('should allow setting useWrapMode', function(done) {
var charW = editor.ace.renderer.layerConfig.characterWidth; var charW = editor.ace.renderer.layerConfig.characterWidth;
@ -253,16 +253,22 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
doc.value = Array(17).join("a very long string to be wrapped "); doc.value = Array(17).join("a very long string to be wrapped ");
render(); render();
bar.$ext.style.width = "1000px"; bar.$ext.style.width = "1000px";
expect(document.querySelector(".ace_gutter-cell").offsetHeight).to.equal(lineHeight); expect(document.querySelector(".ace_gutter-cell").offsetHeight).to.equal(lineHeight);
editor.setOption("useWrapMode", true); editor.setOption("useWrapMode", true);
render(); render();
expect(Math.ceil(document.querySelector(".ace_gutter-cell").offsetHeight)).to.equal(lineHeight * 7); expect(Math.ceil(document.querySelector(".ace_gutter-cell").offsetHeight)).to.equal(lineHeight * 7);
// check that wrap to view setting is not lost when user settings are changes
settings.set("user/ace/@selectionStyle", "line");
expect(editor.ace.getOption("selectionStyle")).to.equal("line");
settings.set("user/ace/@selectionStyle", "text");
render();
expect(editor.ace.getOption("selectionStyle")).to.equal("text");
expect(editor.ace.session.getOption("wrap")).to.equal("printMargin");
done(); done();
}); });
it('should allow setting wrapToView', function(done) { it('should allow setting wrapToView', function(done) {
@ -275,6 +281,7 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
expect(cols).to.equal(ace.session.getWrapLimit()); expect(cols).to.equal(ace.session.getWrapLimit());
expect(document.querySelector(".ace_gutter-cell").offsetHeight).to.equal(lineHeight * ace.session.getRowLength(0)); expect(document.querySelector(".ace_gutter-cell").offsetHeight).to.equal(lineHeight * ace.session.getRowLength(0));
done(); done();
}); });
it('should allow setting wrapBehavioursEnabled', function(done) { it('should allow setting wrapBehavioursEnabled', function(done) {