File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -209,15 +209,14 @@ class TextBuffer {
209209 }
210210
211211 getExtent ( ) {
212- return textExtent ( this . _text )
212+ const text = this . _text
213+ const starts = this . _getLineStarts ( )
214+ const lastRow = starts . length - 1
215+ return { row : lastRow , column : text . length - starts [ lastRow ] }
213216 }
214217
215218 getLineCount ( ) {
216- let count = 1
217- for ( let i = 0 ; i < this . _text . length ; i ++ ) {
218- if ( this . _text . charCodeAt ( i ) === 10 ) count ++
219- }
220- return count
219+ return this . _getLineStarts ( ) . length
221220 }
222221
223222 // ---------------------------------------------------------------------------
@@ -315,7 +314,7 @@ class TextBuffer {
315314 if ( row < 0 || row == null ) row = 0
316315 if ( column < 0 || column == null ) column = 0
317316
318- const ext = textExtent ( this . _text )
317+ const ext = this . getExtent ( )
319318 if ( row > ext . row ) { row = ext . row ; column = ext . column }
320319 else if ( row === ext . row && column > ext . column ) { column = ext . column }
321320
You can’t perform that action at this time.
0 commit comments