From aa404a316dcdfcf8a25c59c1fcd42a5ad343e94f Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 30 Sep 2013 17:21:28 -0700 Subject: [PATCH] Don't allow NaNs --- src/editor.coffee | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/editor.coffee b/src/editor.coffee index 369fcf54f..b07311cce 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -1400,14 +1400,18 @@ class Editor extends View # # Returns a {Number}. getFirstVisibleScreenRow: -> - Math.floor(@scrollTop() / @lineHeight) + screenRow = Math.floor(@scrollTop() / @lineHeight) + screenRow = 0 if isNaN(screenRow) + screenRow # Retrieves the number of the row that is visible and currently at the bottom of the editor. # # Returns a {Number}. getLastVisibleScreenRow: -> calculatedRow = Math.ceil((@scrollTop() + @scrollView.height()) / @lineHeight) - 1 - Math.max(0, Math.min(@getScreenLineCount() - 1, calculatedRow)) + screenRow = Math.max(0, Math.min(@getScreenLineCount() - 1, calculatedRow)) + screenRow = 0 if isNaN(screenRow) + screenRow # Given a row number, identifies if it is currently visible. #