From 46c97ee2b2fbfeb1210118087dcd754cc8f793b4 Mon Sep 17 00:00:00 2001 From: joshaber Date: Tue, 26 Apr 2016 16:14:25 -0400 Subject: [PATCH 1/2] Provide a default assert implementation if one isn't passed in. --- src/text-editor.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index a61afea17..6ceedf943 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -101,8 +101,8 @@ class TextEditor extends Model throw new Error("Must pass a config parameter when constructing TextEditors") unless @config? throw new Error("Must pass a clipboard parameter when constructing TextEditors") unless @clipboard? throw new Error("Must pass a grammarRegistry parameter when constructing TextEditors") unless @grammarRegistry? - throw new Error("Must pass an assert parameter when constructing TextEditors") unless @assert? + @assert ?= @defaultAssert.bind(this) @firstVisibleScreenRow ?= 0 @firstVisibleScreenColumn ?= 0 @emitter = new Emitter @@ -3365,6 +3365,9 @@ class TextEditor extends Model @emitter.emit 'will-insert-text', willInsertEvent result + defaultAssert: (condition, message, callback) -> + condition + ### Section: Language Mode Delegated Methods ### From 76d8421963e1712f13c2808f1a2725011322080e Mon Sep 17 00:00:00 2001 From: joshaber Date: Thu, 28 Apr 2016 09:50:01 -0400 Subject: [PATCH 2/2] Inline the no-op assert. --- src/text-editor.coffee | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index e3300a3b2..8779cd973 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -101,7 +101,7 @@ class TextEditor extends Model throw new Error("Must pass a clipboard parameter when constructing TextEditors") unless @clipboard? throw new Error("Must pass a grammarRegistry parameter when constructing TextEditors") unless @grammarRegistry? - @assert ?= @defaultAssert.bind(this) + @assert ?= (condition) -> condition @firstVisibleScreenRow ?= 0 @firstVisibleScreenColumn ?= 0 @emitter = new Emitter @@ -3364,9 +3364,6 @@ class TextEditor extends Model @emitter.emit 'will-insert-text', willInsertEvent result - defaultAssert: (condition, message, callback) -> - condition - ### Section: Language Mode Delegated Methods ###