FoldSuggester can return a row range of a foldable syntactic region starting at a given row

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-05-30 16:00:59 -06:00
parent e10383a9e9
commit 84318277ba
3 changed files with 28 additions and 4 deletions

View File

@@ -1,6 +1,13 @@
module.exports =
class AceFoldAdaptor
constructor: (@buffer) ->
foldWidgets: {}
constructor: (@highlighter) ->
@buffer = @highlighter.buffer
getLine: (bufferRow) ->
@buffer.lineForRow(bufferRow)
$findClosingBracket: (bracketType, bufferPosition) ->
@highlighter.findClosingBracket([bufferPosition.row, bufferPosition.column - 1])

View File

@@ -2,9 +2,16 @@ AceFoldAdaptor = require 'ace-fold-adaptor'
module.exports =
class FoldSuggester
constructor: (@buffer) ->
constructor: (@highlighter) ->
@buffer = @highlighter.buffer
@aceFoldMode = @buffer.getMode().foldingRules
@aceFoldAdaptor = new AceFoldAdaptor(@buffer)
@aceFoldAdaptor = new AceFoldAdaptor(@highlighter)
isBufferRowFoldable: (bufferRow) ->
@aceFoldMode?.getFoldWidget(@aceFoldAdaptor, null, bufferRow) == "start"
rowRangeForFoldAtBufferRow: (bufferRow) ->
if aceRange = @aceFoldMode?.getFoldWidgetRange(@aceFoldAdaptor, null, bufferRow)
[aceRange.start.row + 1, aceRange.end.row]
else
null