@@ -2010,39 +2010,31 @@ module FourSlash {
20102010
20112011 // Get the text of the entire line the caret is currently at
20122012 private getCurrentLineContent ( ) {
2013- // The current caret position (in line/col terms)
2014- var line = this . getCurrentCaretFilePosition ( ) . line ;
2015- // The line/col of the start of this line
2016- var pos = this . languageServiceAdapterHost . lineColToPosition ( this . activeFile . fileName , line , 1 ) ;
2017- // The index of the current file
2013+ var text = this . getFileContent ( this . activeFile . fileName )
20182014
2019- // The text from the start of the line to the end of the file
2020- var text = this . getFileContent ( this . activeFile . fileName ) . substring ( pos ) ;
2015+ var pos = this . currentCaretPosition ;
2016+ var startPos = pos , endPos = pos ;
20212017
2022- // Truncate to the first newline
2023- var newlinePos = text . indexOf ( '\n' ) ;
2024- if ( newlinePos === - 1 ) {
2025- return text ;
2026- }
2027- else {
2028- if ( text . charAt ( newlinePos - 1 ) === '\r' ) {
2029- newlinePos -- ;
2018+ while ( startPos > 0 ) {
2019+ var ch = text . charCodeAt ( startPos - 1 ) ;
2020+ if ( ch === ts . CharacterCodes . carriageReturn || ch === ts . CharacterCodes . lineFeed ) {
2021+ break ;
20302022 }
2031- return text . substr ( 0 , newlinePos ) ;
2032- }
2033- }
20342023
2035- private getCurrentCaretFilePosition ( ) {
2036- var result = this . languageServiceAdapterHost . positionToZeroBasedLineAndCharacter ( this . activeFile . fileName , this . currentCaretPosition ) ;
2037- if ( result . line >= 0 ) {
2038- result . line ++ ;
2024+ startPos -- ;
20392025 }
20402026
2041- if ( result . character >= 0 ) {
2042- result . character ++ ;
2027+ while ( endPos < text . length ) {
2028+ var ch = text . charCodeAt ( endPos ) ;
2029+
2030+ if ( ch === ts . CharacterCodes . carriageReturn || ch === ts . CharacterCodes . lineFeed ) {
2031+ break ;
2032+ }
2033+
2034+ endPos ++ ;
20432035 }
20442036
2045- return result ;
2037+ return text . substring ( startPos , endPos ) ;
20462038 }
20472039
20482040 private assertItemInCompletionList ( items : ts . CompletionEntry [ ] , name : string , text ?: string , documentation ?: string , kind ?: string ) {
0 commit comments