 			$scope.pdf.view = 'errors'
 			$scope.pdf.renderingError = true
 
+		autoCompileTimeout = null
 		triggerAutoCompile = () ->
-			if (!ide.$scope.hasLintingError)
-				$scope.recompile(isBackgroundAutoCompile: true)
+			return if autoCompileTimeout
+
+			timeSinceLastCompile = Date.now() - $scope.recompiledAt
+
+			if timeSinceLastCompile >= AUTO_COMPILE_TIMEOUT
+				if (!ide.$scope.hasLintingError)
+					$scope.recompile(isBackgroundAutoCompile: true)
+			else
+				# Extend remainder of timeout
+				autoCompileTimeout = setTimeout () ->
+					autoCompileTimeout = null
+					triggerAutoCompile()
+				, AUTO_COMPILE_TIMEOUT - timeSinceLastCompile
 
 		autoCompileListener = null
 		toggleAutoCompile = (enabling) ->
 			if enabling
-				autoCompileListener = ide.$scope.$on "ide:opAcknowledged", _.debounce(triggerAutoCompile, AUTO_COMPILE_TIMEOUT)
+				autoCompileListener = ide.$scope.$on "ide:opAcknowledged", _.debounce(triggerAutoCompile, OP_ACKNOWLEDGEMENT_TIMEOUT)
 			else
 				autoCompileListener() if autoCompileListener
 				autoCompileListener = null

	"services/log-hints-feedback"
], (App, Ace, HumanReadableLogs, BibLogParser) ->
	AUTO_COMPILE_TIMEOUT = 5000

	App.controller "PdfController", ($scope, $http, ide, $modal, synctex, event_tracking, logHintsFeedback, localStorage) ->
		# enable per-user containers by default

					$scope.pdf.renderingError = false
					$scope.pdf.error = true
					$scope.pdf.view = 'errors'
				.finally () ->
					$scope.recompiledAt = Date.now()

		# This needs to be public.
		ide.$scope.recompile = $scope.recompile
