TextRange
Import :
const TextRange = brackets.getModule("document/TextRange")
TextRange
Kind: global class
- TextRange
- new TextRange(document, startLine, endLine)
- .document :
Document
- .startLine :
number
- .endLine :
number
- .dispose()
new TextRange(document, startLine, endLine)
Stores a range of lines that is automatically maintained as the Document changes. The range MAY drop out of sync with the Document in certain edge cases; startLine & endLine will become null when that happens.
Important: you must dispose() a TextRange when you're done with it. Because TextRange addRef()s the Document (in order to listen to it), you will leak Documents otherwise.
TextRange dispatches these events:
- change -- When the range boundary line numbers change (due to a Document change)
- contentChange -- When the actual content of the range changes. This might or might not be accompanied by a change in the boundary line numbers.
- lostSync -- When the backing Document changes in such a way that the range can no longer accurately be maintained. Generally, occurs whenever an edit spans a range boundary. After this, startLine & endLine will be unusable (set to null). Also occurs when the document is deleted, though startLine & endLine won't be modified These events only ever occur in response to Document changes, so if you are already listening to the Document, you could ignore the TextRange events and just read its updated value in your own Document change handler.
Param | Type | Description |
---|---|---|
document | Document | |
startLine | number | First line in range (0-based, inclusive) |
endLine | number | Last line in range (0-based, inclusive) |
textRange.document : Document
Containing document
Kind: instance property of TextRange
textRange.startLine : number
Starting Line
Kind: instance property of TextRange
textRange.endLine : number
Ending Line
Kind: instance property of TextRange
textRange.dispose()
Detaches from the Document. The TextRange will no longer update or send change events
Kind: instance method of TextRange
EventDispatcher
Kind: global variable