mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 04:48:44 +03:00
Support bundles with foldingStopMarker under Preferences/
This commit is contained in:
parent
b8631ac83b
commit
8ce6810179
@ -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
|
||||
|
||||
|
@ -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) ->
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user