mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
Merge branch 'master' into load-subdirs
This commit is contained in:
commit
dc9aba5fca
50 files changed
+1124
-220
No files matched your search
@@ -38,6 +38,7 @@ define(function (require, exports, module) {
|
||||
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
|
||||
StringUtils = brackets.getModule("utils/StringUtils"),
|
||||
StringMatch = brackets.getModule("utils/StringMatch"),
|
||||
LanguageManager = brackets.getModule("language/LanguageManager"),
|
||||
HintUtils = require("HintUtils"),
|
||||
ScopeManager = require("ScopeManager"),
|
||||
Session = require("Session"),
|
||||
@@ -210,18 +211,18 @@ define(function (require, exports, module) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (token.className === null) {
|
||||
if (token.type === null) {
|
||||
token = session.getNextTokenOnLine(cursor);
|
||||
}
|
||||
|
||||
if (lastToken && lastToken.className === null) {
|
||||
if (lastToken && lastToken.type === null) {
|
||||
lastToken = session.getNextTokenOnLine(cachedCursor);
|
||||
}
|
||||
|
||||
// Both of the tokens should never be null (happens when token is off
|
||||
// the end of the line), so one is null then close the hints.
|
||||
if (!lastToken || !token ||
|
||||
token.className !== lastToken.className) {
|
||||
token.type !== lastToken.type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -235,6 +236,18 @@ define(function (require, exports, module) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean} - true if the document is a html file
|
||||
*/
|
||||
function isHTMLFile(document) {
|
||||
var languageID = LanguageManager.getLanguageForPath(document.file.fullPath).getId();
|
||||
return languageID === "html";
|
||||
}
|
||||
|
||||
function isInlineScript(editor) {
|
||||
return editor.getModeForSelection() === "javascript";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether hints are available for a given editor context
|
||||
*
|
||||
@@ -244,6 +257,12 @@ define(function (require, exports, module) {
|
||||
*/
|
||||
JSHints.prototype.hasHints = function (editor, key) {
|
||||
if (session && HintUtils.hintableKey(key)) {
|
||||
|
||||
if (isHTMLFile(session.editor.document)) {
|
||||
if (!isInlineScript(session.editor)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var cursor = session.getCursor(),
|
||||
token = session.getToken(cursor);
|
||||
|
||||
@@ -292,8 +311,7 @@ define(function (require, exports, module) {
|
||||
// Compute fresh hints if none exist, or if the session
|
||||
// type has changed since the last hint computation
|
||||
if (this.needNewHints(session)) {
|
||||
var offset = session.getOffset(),
|
||||
scopeResponse = ScopeManager.requestHints(session, session.editor.document, offset);
|
||||
var scopeResponse = ScopeManager.requestHints(session, session.editor.document);
|
||||
|
||||
if (scopeResponse.hasOwnProperty("promise")) {
|
||||
var $deferredHints = $.Deferred();
|
||||
@@ -535,7 +553,7 @@ define(function (require, exports, module) {
|
||||
installEditorListeners(EditorManager.getActiveEditor());
|
||||
|
||||
var jsHints = new JSHints();
|
||||
CodeHintManager.registerHintProvider(jsHints, [HintUtils.LANGUAGE_ID], 0);
|
||||
CodeHintManager.registerHintProvider(jsHints, [HintUtils.LANGUAGE_ID, "html"], 0);
|
||||
|
||||
// for unit testing
|
||||
exports.getSession = getSession;
|
||||
|
||||
Reference in new issue
Block a user