mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Fixes code hint tests by controlling worker resets.
Previously, the web worker would be restarted at somewhat random times during test runs (after a specific number of hints was requested). This change forces the worker to start afresh with each test and switches the worker so that it doesn't reset during any of the tests.
This commit is contained in:
1 parent
598007f70d
commit
f80c0c9d98
5 files changed
+171
-41
No files matched your search
@@ -55,6 +55,27 @@ define(function (require, exports, module) {
|
||||
matcher = null, // string matcher for hints
|
||||
ignoreChange; // can ignore next "change" event if true;
|
||||
|
||||
/**
|
||||
* Sets the configuration, generally for testing/debugging use.
|
||||
* Configuration keys are merged into the current configuration.
|
||||
* The Tern worker is automatically updated to the new config as well.
|
||||
*
|
||||
* * debug: Set to true if you want verbose logging
|
||||
* * noReset: Set to true if you don't want the worker to restart periodically
|
||||
*
|
||||
* @param {Object} configUpdate keys/values to merge into the config
|
||||
*/
|
||||
function setConfig(configUpdate) {
|
||||
var config = setConfig.config;
|
||||
Object.keys(configUpdate).forEach(function (key) {
|
||||
config[key] = configUpdate[key];
|
||||
});
|
||||
|
||||
ScopeManager._setConfig(configUpdate);
|
||||
}
|
||||
|
||||
setConfig.config = {};
|
||||
|
||||
/**
|
||||
* Get the value of current session.
|
||||
* Used for unit testing.
|
||||
@@ -79,6 +100,10 @@ define(function (require, exports, module) {
|
||||
var trimmedQuery,
|
||||
formattedHints;
|
||||
|
||||
if (setConfig.config.debug) {
|
||||
console.debug("Hints", _.pluck(hints, "label"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a formatted list of hints with the query substring
|
||||
* highlighted.
|
||||
@@ -578,8 +603,10 @@ define(function (require, exports, module) {
|
||||
* for changes
|
||||
*/
|
||||
function uninstallEditorListeners(editor) {
|
||||
$(editor)
|
||||
.off(HintUtils.eventName("change"));
|
||||
if (editor) {
|
||||
$(editor)
|
||||
.off(HintUtils.eventName("change"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -745,9 +772,12 @@ define(function (require, exports, module) {
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
// Register quickEditHelper.
|
||||
brackets._jsCodeHintsHelper = quickEditHelper;
|
||||
|
||||
// Configuration function used for debugging
|
||||
brackets.configureJSCodeHints = setConfig;
|
||||
|
||||
ExtensionUtils.loadStyleSheet(module, "styles/brackets-js-hints.css");
|
||||
|
||||
|
||||
Reference in new issue
Block a user