Merge pull request #3692 from dloverin/first-hint-perf

prime pump to improve first hint performance
This commit is contained in:
Erik Tierney committed 2013-05-03 10:16:06 -07:00
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);