diff --git a/apply.js b/apply.js index f601161c..f7d661cb 100644 --- a/apply.js +++ b/apply.js @@ -256,6 +256,13 @@ function initObserver() { getDynamicIFrames(document).forEach(addDocumentStylesToIFrame); return; } + // move the check out of current execution context + // because some same-domain (!) iframes fail to load when their "contentDocument" is accessed (!) + // namely gmail's old chat iframe talkgadget.google.com + setTimeout(process.bind(null, mutations), 0); + }); + + function process(mutations) { for (var m = 0, ml = mutations.length; m < ml; m++) { var mutation = mutations[m]; if (mutation.type === "childList") { @@ -267,7 +274,7 @@ function initObserver() { } } } - }); + } iframeObserver.start = function() { // will be ignored by browser if already observing diff --git a/edit.js b/edit.js index 894e463d..6f6dc026 100644 --- a/edit.js +++ b/edit.js @@ -124,7 +124,8 @@ function initCodeMirror() { foldGutter: true, gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"], matchBrackets: true, - lint: CodeMirror.lint.css, + lint: {getAnnotations: CodeMirror.lint.css, delay: prefs.getPref("editor.lintDelay")}, + lintReportDelay: prefs.getPref("editor.lintReportDelay"), styleActiveLine: true, theme: "default", keyMap: prefs.getPref("editor.keyMap"), @@ -830,22 +831,34 @@ function updateLintReport(cm, delay) { // by settings its internal delay to 1ms and restoring it back later var lintOpt = editors[0].state.lint.options; setTimeout((function(opt, delay) { - opt.delay = delay; + opt.delay = delay == 1 ? opt.delay : delay; // options object is shared between editors update(this); }).bind(cm, lintOpt, lintOpt.delay), delay); lintOpt.delay = 1; return; } + // user is editing right now: postpone updating the report for the new issues (default: 500ms lint + 4500ms) + // or update it as soon as possible (default: 500ms lint + 100ms) in case an existing issue was just fixed + var postponeNewIssues = delay == undefined; var state = cm.state.lint; clearTimeout(state.reportTimeout); - state.reportTimeout = setTimeout(update.bind(cm), (state.options.delay || 500) + 4500); + state.reportTimeout = setTimeout(update.bind(cm), state.options.delay + 100); + function update() { // this == cm var scope = this ? [this] : editors; var changed = false; + var fixedOldIssues = false; scope.forEach(function(cm) { + var oldMarkers = cm.state.lint.markedLast || {}; + var newMarkers = {}; var html = cm.state.lint.marked.length == 0 ? "" : "
" + cm.state.lint.marked.map(function(mark) { var info = mark.__annotation; + var pos = info.from.line + "," + info.from.ch; + if (oldMarkers[pos] == info.message) { + delete oldMarkers[pos]; + } + newMarkers[pos] = info.message; return "