Support bundles with foldingStopMarker under Preferences/

This commit is contained in:
Kevin Sawicki 2012-10-09 16:49:46 -07:00
parent b8631ac83b
commit 8ce6810179
3 changed files with 10 additions and 4 deletions

View File

@ -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

View File

@ -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) ->

View File

@ -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)