mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Merge pull request #3692 from dloverin/first-hint-perf
prime pump to improve first hint performance
This commit is contained in:
commit
a5b7100bd8
2 files changed
+9
-4
No files matched your search
@@ -54,7 +54,6 @@ define(function (require, exports, module) {
|
||||
cachedToken = null, // the token used in the current hinting session
|
||||
matcher = null; // string matcher for hints
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of current session.
|
||||
* Used for unit testing.
|
||||
@@ -427,11 +426,17 @@ define(function (require, exports, module) {
|
||||
* information, and reject any pending deferred requests.
|
||||
*
|
||||
* @param {Editor} editor - editor context to be initialized.
|
||||
* @param {boolean} primePump - true if the pump should be primed.
|
||||
*/
|
||||
function initializeSession(editor) {
|
||||
function initializeSession(editor, primePump) {
|
||||
ScopeManager.handleEditorChange(editor.document);
|
||||
session = new Session(editor);
|
||||
cachedHints = null;
|
||||
|
||||
// prime pump for hints so the first user request is fast
|
||||
if (primePump) {
|
||||
ScopeManager.requestHints(session, session.editor.document, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -447,7 +452,7 @@ define(function (require, exports, module) {
|
||||
cachedType = null;
|
||||
|
||||
if (editor && editor.getLanguageForSelection().getId() === HintUtils.LANGUAGE_ID) {
|
||||
initializeSession(editor);
|
||||
initializeSession(editor, true);
|
||||
$(editor)
|
||||
.on(HintUtils.eventName("change"), function () {
|
||||
ScopeManager.handleFileChange(editor.document);
|
||||
|
||||
@@ -332,7 +332,7 @@ define(function (require, exports, module) {
|
||||
// create Editor instance (containing a CodeMirror instance)
|
||||
runs(function () {
|
||||
testEditor = createMockEditor(testDoc);
|
||||
JSCodeHints.initializeSession(testEditor);
|
||||
JSCodeHints.initializeSession(testEditor, false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user