From 8ce68101799bf4d93ad5d66f4c237c47dfea0aae Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 9 Oct 2012 16:49:46 -0700 Subject: [PATCH] Support bundles with foldingStopMarker under Preferences/ --- src/app/language-mode.coffee | 3 ++- src/app/text-mate-bundle.coffee | 7 +++++++ src/app/text-mate-grammar.coffee | 4 +--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/language-mode.coffee b/src/app/language-mode.coffee index 1c7604c6d..312a0f2f5 100644 --- a/src/app/language-mode.coffee +++ b/src/app/language-mode.coffee @@ -73,11 +73,12 @@ class LanguageMode return null unless @doesBufferRowStartFold(bufferRow) startIndentation = @editSession.indentationForBufferRow(bufferRow) + scopes = @tokenizedBuffer.scopesForPosition([bufferRow, 0]) for row in [(bufferRow + 1)..@editSession.getLastBufferRow()] continue if @editSession.isBufferRowBlank(row) indentation = @editSession.indentationForBufferRow(row) if indentation <= startIndentation - includeRowInFold = indentation == startIndentation and @grammar.foldEndRegex.search(@editSession.lineForBufferRow(row)) + includeRowInFold = indentation == startIndentation and TextMateBundle.foldEndRegexForScope(@grammar, scopes[0]).search(@editSession.lineForBufferRow(row)) foldEndRow = row if includeRowInFold break diff --git a/src/app/text-mate-bundle.coffee b/src/app/text-mate-bundle.coffee index 6bdc04aa6..8390027cb 100644 --- a/src/app/text-mate-bundle.coffee +++ b/src/app/text-mate-bundle.coffee @@ -56,6 +56,13 @@ class TextMateBundle if source = @getPreferenceInScope(scope, 'decreaseIndentPattern') new OnigRegExp(source) + @foldEndRegexForScope: (grammar, scope) -> + marker = @getPreferenceInScope(scope, 'foldingStopMarker') + if marker + new OnigRegExp(marker) + else + new OnigRegExp(grammar.foldingStopMarker) + grammars: null constructor: (@path) -> diff --git a/src/app/text-mate-grammar.coffee b/src/app/text-mate-grammar.coffee index 601acf259..590cfb206 100644 --- a/src/app/text-mate-grammar.coffee +++ b/src/app/text-mate-grammar.coffee @@ -14,14 +14,12 @@ class TextMateGrammar name: null fileTypes: null scopeName: null - foldEndRegex: null repository: null initialRule: null - constructor: ({ @name, @fileTypes, @scopeName, patterns, repository, foldingStopMarker}) -> + constructor: ({ @name, @fileTypes, @scopeName, patterns, repository, @foldingStopMarker}) -> @initialRule = new Rule(this, {@scopeName, patterns}) @repository = {} - @foldEndRegex = new OnigRegExp(foldingStopMarker) if foldingStopMarker for name, data of repository @repository[name] = new Rule(this, data)