Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable lint tooltips #1402

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 14 additions & 7 deletions addon/lint/lint.js
Expand Up @@ -50,17 +50,21 @@ CodeMirror.validate = (function() {
state.marked.length = 0; state.marked.length = 0;
} }


function makeMarker(labels, severity, multiple) { function makeMarker(cm, labels, severity, multiple) {
var marker = document.createElement("div"), inner = marker; var marker = document.createElement("div"), inner = marker;
var state = cm._lintState;
marker.className = "CodeMirror-lint-marker-" + severity; marker.className = "CodeMirror-lint-marker-" + severity;
if (multiple) { if (multiple) {
inner = marker.appendChild(document.createElement("div")); inner = marker.appendChild(document.createElement("div"));
inner.className = "CodeMirror-lint-marker-multiple"; inner.className = "CodeMirror-lint-marker-multiple";
} }


var tooltip; var tooltip;
CodeMirror.on(inner, "mouseover", function(e) { tooltip = showTooltip(e, labels); });
CodeMirror.on(inner, "mouseout", function() { if (tooltip) hideTooltip(tooltip); }); if (!state.options.disableTooltips) {
CodeMirror.on(inner, "mouseover", function(e) { tooltip = showTooltip(e, labels); });
CodeMirror.on(inner, "mouseout", function() { if (tooltip) hideTooltip(tooltip); });
}


return marker; return marker;
} }
Expand Down Expand Up @@ -95,7 +99,7 @@ CodeMirror.validate = (function() {
else else
updateLinting(cm, options.getAnnotations(cm.getValue())); updateLinting(cm, options.getAnnotations(cm.getValue()));
} }

function updateLinting(cm, annotationsNotSorted) { function updateLinting(cm, annotationsNotSorted) {
clearMarks(cm); clearMarks(cm);
var state = cm._lintState, options = state.options; var state = cm._lintState, options = state.options;
Expand Down Expand Up @@ -125,7 +129,7 @@ CodeMirror.validate = (function() {
} }


if (state.hasGutter) if (state.hasGutter)
cm.setGutterMarker(line, GUTTER_ID, makeMarker(tipLabel, maxSeverity, anns.length > 1)); cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1));
} }
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm); if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
} }
Expand Down Expand Up @@ -170,13 +174,16 @@ CodeMirror.validate = (function() {
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm._lintState.onMouseOver); CodeMirror.off(cm.getWrapperElement(), "mouseover", cm._lintState.onMouseOver);
delete cm._lintState; delete cm._lintState;
} }

if (val) { if (val) {
var gutters = cm.getOption("gutters"), hasLintGutter = false; var gutters = cm.getOption("gutters"), hasLintGutter = false;
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true; for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
var state = cm._lintState = new LintState(cm, parseOptions(val), hasLintGutter); var state = cm._lintState = new LintState(cm, parseOptions(val), hasLintGutter);
cm.on("change", onChange); cm.on("change", onChange);
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
if (!state.options.disableTooltips)
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);

startLinting(cm); startLinting(cm);
} }
}); });
Expand Down