From b97f317cd1cdc42a95c37274ed2818f665fd921f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 9 Aug 2016 15:20:00 -0700 Subject: [PATCH] Remove fallbacks for scoped properties in TextEditor Signed-off-by: Nathan Sobo --- src/language-mode.coffee | 14 ++++++-------- src/text-editor.coffee | 12 ++++++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/language-mode.coffee b/src/language-mode.coffee index 2ffe57f19..a3ba2e664 100644 --- a/src/language-mode.coffee +++ b/src/language-mode.coffee @@ -25,8 +25,9 @@ class LanguageMode # endRow - The row {Number} to end at toggleLineCommentsForBufferRows: (start, end) -> scope = @editor.scopeDescriptorForBufferPosition([start, 0]) - {commentStartString, commentEndString} = @commentStartAndEndStringsForScope(scope) - return unless commentStartString? + commentStrings = @editor.getCommentStrings(scope) + return unless commentStrings? + {commentStartString, commentEndString} = commentStrings buffer = @editor.buffer commentStartRegexString = _.escapeRegExp(commentStartString).replace(/(\s+)$/, '(?:$1)?') @@ -194,10 +195,10 @@ class LanguageMode # the same type (comments next to source code). rowRangeForParagraphAtBufferRow: (bufferRow) -> scope = @editor.scopeDescriptorForBufferPosition([bufferRow, 0]) - {commentStartString, commentEndString} = @commentStartAndEndStringsForScope(scope) + commentStrings = @editor.getCommentStrings(scope) commentStartRegex = null - if commentStartString? and not commentEndString? - commentStartRegexString = _.escapeRegExp(commentStartString).replace(/(\s+)$/, '(?:$1)?') + if commentStrings?.commentStartString? and not commentStrings.commentEndString? + commentStartRegexString = _.escapeRegExp(commentStrings.commentStartString).replace(/(\s+)$/, '(?:$1)?') commentStartRegex = new OnigRegExp("^(\\s*)(#{commentStartRegexString})") filterCommentStart = (line) -> @@ -347,6 +348,3 @@ class LanguageMode foldEndRegexForScopeDescriptor: (scopeDescriptor) -> @cacheRegex(@editor.getFoldEndPattern(scopeDescriptor)) - - commentStartAndEndStringsForScope: (scope) -> - @editor.getCommentStrings(scope) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 94e4c559d..c8b0adf4b 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -3432,22 +3432,22 @@ class TextEditor extends Model # # Returns a {String} containing the non-word characters. getNonWordCharacters: (scopes) -> - (scopes and @scopedSettingsDelegate?.getNonWordCharacters?(scopes)) ? @nonWordCharacters + @scopedSettingsDelegate?.getNonWordCharacters?(scopes) ? @nonWordCharacters getCommentStrings: (scopes) -> - (scopes and @scopedSettingsDelegate?.getCommentStrings?(scopes)) ? @commentStrings + @scopedSettingsDelegate?.getCommentStrings?(scopes) getIncreaseIndentPattern: (scopes) -> - (scopes and @scopedSettingsDelegate?.getIncreaseIndentPattern?(scopes)) ? @increaseIndentPattern + @scopedSettingsDelegate?.getIncreaseIndentPattern?(scopes) getDecreaseIndentPattern: (scopes) -> - (scopes and @scopedSettingsDelegate?.getDecreaseIndentPattern?(scopes)) ? @decreaseIndentPattern + @scopedSettingsDelegate?.getDecreaseIndentPattern?(scopes) getDecreaseNextIndentPattern: (scopes) -> - (scopes and @scopedSettingsDelegate?.getDecreaseNextIndentPattern?(scopes)) ? @decreaseNextIndentPattern + @scopedSettingsDelegate?.getDecreaseNextIndentPattern?(scopes) getFoldEndPattern: (scopes) -> - (scopes and @scopedSettingsDelegate?.getFoldEndPattern?(scopes)) ? @foldEndPattern + @scopedSettingsDelegate?.getFoldEndPattern?(scopes) ### Section: Event Handlers