commit
						7f0557df57
					
				
							
								
								
									
										9
									
								
								apply.js
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								apply.js
									
									
									
									
									
								
							|  | @ -256,6 +256,13 @@ function initObserver() { | ||||||
| 			getDynamicIFrames(document).forEach(addDocumentStylesToIFrame); | 			getDynamicIFrames(document).forEach(addDocumentStylesToIFrame); | ||||||
| 			return; | 			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++) { | 		for (var m = 0, ml = mutations.length; m < ml; m++) { | ||||||
| 			var mutation = mutations[m]; | 			var mutation = mutations[m]; | ||||||
| 			if (mutation.type === "childList") { | 			if (mutation.type === "childList") { | ||||||
|  | @ -267,7 +274,7 @@ function initObserver() { | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	}); | 	} | ||||||
| 
 | 
 | ||||||
| 	iframeObserver.start = function() { | 	iframeObserver.start = function() { | ||||||
| 		// will be ignored by browser if already observing
 | 		// will be ignored by browser if already observing
 | ||||||
|  |  | ||||||
							
								
								
									
										32
									
								
								edit.js
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								edit.js
									
									
									
									
									
								
							|  | @ -124,7 +124,8 @@ function initCodeMirror() { | ||||||
| 		foldGutter: true, | 		foldGutter: true, | ||||||
| 		gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"], | 		gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter", "CodeMirror-lint-markers"], | ||||||
| 		matchBrackets: true, | 		matchBrackets: true, | ||||||
| 		lint: CodeMirror.lint.css, | 		lint: {getAnnotations: CodeMirror.lint.css, delay: prefs.getPref("editor.lintDelay")}, | ||||||
|  | 		lintReportDelay: prefs.getPref("editor.lintReportDelay"), | ||||||
| 		styleActiveLine: true, | 		styleActiveLine: true, | ||||||
| 		theme: "default", | 		theme: "default", | ||||||
| 		keyMap: prefs.getPref("editor.keyMap"), | 		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
 | 		// by settings its internal delay to 1ms and restoring it back later
 | ||||||
| 		var lintOpt = editors[0].state.lint.options; | 		var lintOpt = editors[0].state.lint.options; | ||||||
| 		setTimeout((function(opt, delay) { | 		setTimeout((function(opt, delay) { | ||||||
| 			opt.delay = delay; | 			opt.delay = delay == 1 ? opt.delay : delay; // options object is shared between editors
 | ||||||
| 			update(this); | 			update(this); | ||||||
| 		}).bind(cm, lintOpt, lintOpt.delay), delay); | 		}).bind(cm, lintOpt, lintOpt.delay), delay); | ||||||
| 		lintOpt.delay = 1; | 		lintOpt.delay = 1; | ||||||
| 		return; | 		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; | 	var state = cm.state.lint; | ||||||
| 	clearTimeout(state.reportTimeout); | 	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
 | 	function update() { // this == cm
 | ||||||
| 		var scope = this ? [this] : editors; | 		var scope = this ? [this] : editors; | ||||||
| 		var changed = false; | 		var changed = false; | ||||||
|  | 		var fixedOldIssues = false; | ||||||
| 		scope.forEach(function(cm) { | 		scope.forEach(function(cm) { | ||||||
|  | 			var oldMarkers = cm.state.lint.markedLast || {}; | ||||||
|  | 			var newMarkers = {}; | ||||||
| 			var html = cm.state.lint.marked.length == 0 ? "" : "<tbody>" + | 			var html = cm.state.lint.marked.length == 0 ? "" : "<tbody>" + | ||||||
| 				cm.state.lint.marked.map(function(mark) { | 				cm.state.lint.marked.map(function(mark) { | ||||||
| 					var info = mark.__annotation; | 					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 "<tr class='" + info.severity + "'>" + | 					return "<tr class='" + info.severity + "'>" + | ||||||
| 						"<td role='severity' class='CodeMirror-lint-marker-" + info.severity + "'>" + | 						"<td role='severity' class='CodeMirror-lint-marker-" + info.severity + "'>" + | ||||||
| 							info.severity + "</td>" + | 							info.severity + "</td>" + | ||||||
|  | @ -854,13 +867,22 @@ function updateLintReport(cm, delay) { | ||||||
| 						"<td role='col'>" + (info.from.ch+1) + "</td>" + | 						"<td role='col'>" + (info.from.ch+1) + "</td>" + | ||||||
| 						"<td role='message'>" + info.message.replace(/ at line \d.+$/, "") + "</td></tr>"; | 						"<td role='message'>" + info.message.replace(/ at line \d.+$/, "") + "</td></tr>"; | ||||||
| 				}).join("") + "</tbody>"; | 				}).join("") + "</tbody>"; | ||||||
|  | 			cm.state.lint.markedLast = newMarkers; | ||||||
|  | 			fixedOldIssues |= Object.keys(oldMarkers).length > 0; | ||||||
| 			if (cm.state.lint.html != html) { | 			if (cm.state.lint.html != html) { | ||||||
| 				cm.state.lint.html = html; | 				cm.state.lint.html = html; | ||||||
| 				changed = true; | 				changed = true; | ||||||
| 			} | 			} | ||||||
| 		}); | 		}); | ||||||
| 		if (changed) { | 		if (changed) { | ||||||
| 			renderLintReport(true); | 			clearTimeout(state ? state.renderTimeout : undefined); | ||||||
|  | 			if (!postponeNewIssues || fixedOldIssues) { | ||||||
|  | 				renderLintReport(true); | ||||||
|  | 			} else { | ||||||
|  | 				state.renderTimeout = setTimeout(function() { | ||||||
|  | 					renderLintReport(true); | ||||||
|  | 				}, CodeMirror.defaults.lintReportDelay); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | @ -1053,7 +1075,7 @@ function initWithStyle(style) { | ||||||
| 	function add() { | 	function add() { | ||||||
| 		var sectionDiv = addSection(null, queue.shift()); | 		var sectionDiv = addSection(null, queue.shift()); | ||||||
| 		maximizeCodeHeight(sectionDiv, !queue.length); | 		maximizeCodeHeight(sectionDiv, !queue.length); | ||||||
| 		updateLintReport(getCodeMirrorForSection(sectionDiv), 500); | 		updateLintReport(getCodeMirrorForSection(sectionDiv), prefs.getPref("editor.lintDelay")); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -43,6 +43,9 @@ | ||||||
| 				width: 100%; height: 2px; | 				width: 100%; height: 2px; | ||||||
| 				background-color: #fff; | 				background-color: #fff; | ||||||
| 			} | 			} | ||||||
|  | 			.applies-to { | ||||||
|  | 				word-break: break-word; | ||||||
|  | 			} | ||||||
| 			.applies-to, .actions { | 			.applies-to, .actions { | ||||||
| 				padding-left: 15px; | 				padding-left: 15px; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -189,6 +189,8 @@ var prefs = { | ||||||
| 		newline_between_rules: false, | 		newline_between_rules: false, | ||||||
| 		end_with_newline: false | 		end_with_newline: false | ||||||
| 	}, | 	}, | ||||||
|  | 	"editor.lintDelay": 500,        // lint gutter marker update delay, ms
 | ||||||
|  | 	"editor.lintReportDelay": 4500, // lint report update delay, ms
 | ||||||
| 
 | 
 | ||||||
| 	NO_DEFAULT_PREFERENCE: "No default preference for '%s'", | 	NO_DEFAULT_PREFERENCE: "No default preference for '%s'", | ||||||
| 	UNHANDLED_DATA_TYPE: "Default '%s' is of type '%s' - what should be done with it?", | 	UNHANDLED_DATA_TYPE: "Default '%s' is of type '%s' - what should be done with it?", | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user