Parcourir la source

Ensure that time is monotonic when running autocompile

Alasdair Smith il y a 9 ans
Parent
commit
38eaf82c65

+ 4 - 1
services/web/public/coffee/ide/pdf/controllers/PdfController.coffee

@@ -80,8 +80,11 @@ define [
 			return if autoCompileTimeout
 
 			timeSinceLastCompile = Date.now() - $scope.recompiledAt
+			# If time is non-monotonic, assume that the user's system clock has been
+			# changed and continue with recompile
+			isTimeNonMonotonic = timeSinceLastPoll < 0;
 
-			if timeSinceLastCompile >= AUTO_COMPILE_TIMEOUT
+			if isTimeNonMonotonic || timeSinceLastCompile >= AUTO_COMPILE_TIMEOUT
 				if (!ide.$scope.hasLintingError)
 					$scope.recompile(isBackgroundAutoCompile: true)
 			else