diff --git a/python/ycm/client/base_request.py b/python/ycm/client/base_request.py index c5f37718..36388a0a 100644 --- a/python/ycm/client/base_request.py +++ b/python/ycm/client/base_request.py @@ -137,13 +137,15 @@ class BaseRequest( object ): def BuildRequestData( start_column = None, query = None, include_buffer_data = True ): + if start_column is None: + start_column = 0 line, column = vimsupport.CurrentLineAndColumn() filepath = vimsupport.GetCurrentBufferFilepath() request_data = { 'filetypes': vimsupport.CurrentFiletypes(), - 'line_num': line, - 'column_num': column, - 'start_column': start_column, + 'line_num': line + 1, + 'column_num': column + 1, + 'start_column': start_column + 1, 'line_value': vim.current.line, 'filepath': filepath } diff --git a/python/ycm/client/command_request.py b/python/ycm/client/command_request.py index effc5a5c..375cde10 100644 --- a/python/ycm/client/command_request.py +++ b/python/ycm/client/command_request.py @@ -66,8 +66,8 @@ class CommandRequest( BaseRequest ): vim.eval( 'youcompleteme#OpenGoToList()' ) else: vimsupport.JumpToLocation( self._response[ 'filepath' ], - self._response[ 'line_num' ] + 1, - self._response[ 'column_num' ] + 1) + self._response[ 'line_num' ], + self._response[ 'column_num' ] ) @@ -87,7 +87,7 @@ def _BuildQfListItem( goto_data_item ): if 'description' in goto_data_item: qf_item[ 'text' ] = ToUtf8IfNeeded( goto_data_item[ 'description' ] ) if 'line_num' in goto_data_item: - qf_item[ 'lnum' ] = goto_data_item[ 'line_num' ] + 1 + qf_item[ 'lnum' ] = goto_data_item[ 'line_num' ] if 'column_num' in goto_data_item: - qf_item[ 'col' ] = goto_data_item[ 'column_num' ] + qf_item[ 'col' ] = goto_data_item[ 'column_num' ] - 1 return qf_item diff --git a/python/ycm/completers/all/identifier_completer.py b/python/ycm/completers/all/identifier_completer.py index 0eabf240..5baa0eed 100644 --- a/python/ycm/completers/all/identifier_completer.py +++ b/python/ycm/completers/all/identifier_completer.py @@ -160,8 +160,8 @@ class IdentifierCompleter( GeneralCompleter ): def _PreviousIdentifier( min_num_completion_start_chars, request_data ): - line_num = request_data[ 'line_num' ] - column_num = request_data[ 'column_num' ] + line_num = request_data[ 'line_num' ] - 1 + column_num = request_data[ 'column_num' ] - 1 filepath = request_data[ 'filepath' ] contents_per_line = ( request_data[ 'file_data' ][ filepath ][ 'contents' ].split( '\n' ) ) @@ -226,7 +226,7 @@ def _GetCursorIdentifier( request_data ): identifier_end += 1 return identifier_end + 1 - column_num = request_data[ 'column_num' ] + column_num = request_data[ 'column_num' ] - 1 line = request_data[ 'line_value' ] try: diff --git a/python/ycm/completers/all/tests/identifier_completer_test.py b/python/ycm/completers/all/tests/identifier_completer_test.py index 47263133..6ded7173 100644 --- a/python/ycm/completers/all/tests/identifier_completer_test.py +++ b/python/ycm/completers/all/tests/identifier_completer_test.py @@ -25,14 +25,14 @@ def GetCursorIdentifier_StartOfLine_test(): eq_( 'foo', identifier_completer._GetCursorIdentifier( { - 'column_num': 0, + 'column_num': 1, 'line_value': 'foo' } ) ) eq_( 'fooBar', identifier_completer._GetCursorIdentifier( { - 'column_num': 0, + 'column_num': 1, 'line_value': 'fooBar' } ) ) @@ -41,7 +41,7 @@ def GetCursorIdentifier_EndOfLine_test(): eq_( 'foo', identifier_completer._GetCursorIdentifier( { - 'column_num': 2, + 'column_num': 3, 'line_value': 'foo' } ) ) @@ -50,7 +50,7 @@ def GetCursorIdentifier_PastEndOfLine_test(): eq_( '', identifier_completer._GetCursorIdentifier( { - 'column_num': 10, + 'column_num': 11, 'line_value': 'foo' } ) ) @@ -68,7 +68,7 @@ def GetCursorIdentifier_StartOfLine_StopsAtNonIdentifierChar_test(): eq_( 'foo', identifier_completer._GetCursorIdentifier( { - 'column_num': 0, + 'column_num': 1, 'line_value': 'foo(goo)' } ) ) @@ -77,7 +77,7 @@ def GetCursorIdentifier_AtNonIdentifier_test(): eq_( 'goo', identifier_completer._GetCursorIdentifier( { - 'column_num': 3, + 'column_num': 4, 'line_value': 'foo(goo)' } ) ) @@ -86,7 +86,7 @@ def GetCursorIdentifier_WalksForwardForIdentifier_test(): eq_( 'foo', identifier_completer._GetCursorIdentifier( { - 'column_num': 0, + 'column_num': 1, 'line_value': ' foo' } ) ) @@ -95,7 +95,7 @@ def GetCursorIdentifier_FindsNothingForward_test(): eq_( '', identifier_completer._GetCursorIdentifier( { - 'column_num': 4, + 'column_num': 5, 'line_value': 'foo ()***()' } ) ) @@ -104,7 +104,7 @@ def GetCursorIdentifier_SingleCharIdentifier_test(): eq_( 'f', identifier_completer._GetCursorIdentifier( { - 'column_num': 0, + 'column_num': 1, 'line_value': ' f ' } ) ) @@ -113,7 +113,7 @@ def GetCursorIdentifier_StartsInMiddleOfIdentifier_test(): eq_( 'foobar', identifier_completer._GetCursorIdentifier( { - 'column_num': 3, + 'column_num': 4, 'line_value': 'foobar' } ) ) @@ -122,6 +122,6 @@ def GetCursorIdentifier_LineEmpty_test(): eq_( '', identifier_completer._GetCursorIdentifier( { - 'column_num': 11, + 'column_num': 12, 'line_value': '' } ) ) diff --git a/python/ycm/completers/completer.py b/python/ycm/completers/completer.py index b8d582f0..33f367d0 100644 --- a/python/ycm/completers/completer.py +++ b/python/ycm/completers/completer.py @@ -133,7 +133,7 @@ class Completer( object ): def ShouldUseNowInner( self, request_data ): current_line = request_data[ 'line_value' ] - start_column = request_data[ 'start_column' ] + start_column = request_data[ 'start_column' ] - 1 line_length = len( current_line ) if not line_length or start_column - 1 >= line_length: return False diff --git a/python/ycm/completers/cpp/clang_completer.py b/python/ycm/completers/cpp/clang_completer.py index 7e699912..e358e57b 100644 --- a/python/ycm/completers/cpp/clang_completer.py +++ b/python/ycm/completers/cpp/clang_completer.py @@ -85,8 +85,8 @@ class ClangCompleter( Completer ): raise RuntimeError( NO_COMPILE_FLAGS_MESSAGE ) files = self.GetUnsavedFilesVector( request_data ) - line = request_data[ 'line_num' ] + 1 - column = request_data[ 'start_column' ] + 1 + line = request_data[ 'line_num' ] + column = request_data[ 'start_column' ] results = self._completer.CandidatesForLocationInFile( ToUtf8IfNeeded( filename ), line, @@ -136,8 +136,8 @@ class ClangCompleter( Completer ): raise ValueError( NO_COMPILE_FLAGS_MESSAGE ) files = self.GetUnsavedFilesVector( request_data ) - line = request_data[ 'line_num' ] + 1 - column = request_data[ 'column_num' ] + 1 + line = request_data[ 'line_num' ] + column = request_data[ 'column_num' ] return getattr( self._completer, goto_function )( ToUtf8IfNeeded( filename ), line, @@ -217,8 +217,8 @@ class ClangCompleter( Completer ): def GetDetailedDiagnostic( self, request_data ): - current_line = request_data[ 'line_num' ] + 1 - current_column = request_data[ 'column_num' ] + 1 + current_line = request_data[ 'line_num' ] + current_column = request_data[ 'column_num' ] current_file = request_data[ 'filepath' ] if not self._diagnostic_store: @@ -304,7 +304,7 @@ def _FilterDiagnostics( diagnostics ): def _ResponseForLocation( location ): return responses.BuildGoToResponse( location.filename_, - location.line_number_ - 1, - location.column_number_ - 1) + location.line_number_, + location.column_number_ ) diff --git a/python/ycm/completers/cs/cs_completer.py b/python/ycm/completers/cs/cs_completer.py index de6a7937..17a57e5b 100755 --- a/python/ycm/completers/cs/cs_completer.py +++ b/python/ycm/completers/cs/cs_completer.py @@ -157,8 +157,8 @@ class CsharpCompleter( Completer ): def GetDetailedDiagnostic( self, request_data ): - current_line = request_data[ 'line_num' ] + 1 - current_column = request_data[ 'column_num' ] + 1 + current_line = request_data[ 'line_num' ] + current_column = request_data[ 'column_num' ] current_file = request_data[ 'filepath' ] if not self._diagnostic_store: @@ -301,8 +301,8 @@ class CsharpCompleter( Completer ): self._DefaultParameters( request_data ) ) if definition[ 'FileName' ] != None: return responses.BuildGoToResponse( definition[ 'FileName' ], - definition[ 'Line' ] - 1, - definition[ 'Column' ] - 1 ) + definition[ 'Line' ], + definition[ 'Column' ] ) else: raise RuntimeError( 'Can\'t jump to definition' ) @@ -310,11 +310,11 @@ class CsharpCompleter( Completer ): def _DefaultParameters( self, request_data ): """ Some very common request parameters """ parameters = {} - parameters[ 'line' ] = request_data[ 'line_num' ] + 1 - parameters[ 'column' ] = request_data[ 'column_num' ] + 1 + parameters[ 'line' ] = request_data[ 'line_num' ] + parameters[ 'column' ] = request_data[ 'column_num' ] filepath = request_data[ 'filepath' ] - parameters[ 'buffer' ] = request_data[ 'file_data' ][ filepath ][ - 'contents' ] + parameters[ 'buffer' ] = ( + request_data[ 'file_data' ][ filepath ][ 'contents' ] ) parameters[ 'filename' ] = filepath return parameters diff --git a/python/ycm/completers/general/filename_completer.py b/python/ycm/completers/general/filename_completer.py index add03e1b..77195909 100644 --- a/python/ycm/completers/general/filename_completer.py +++ b/python/ycm/completers/general/filename_completer.py @@ -57,7 +57,7 @@ class FilenameCompleter( Completer ): def AtIncludeStatementStart( self, request_data ): - start_column = request_data[ 'start_column' ] + start_column = request_data[ 'start_column' ] - 1 current_line = request_data[ 'line_value' ] filepath = ToUtf8IfNeeded( request_data[ 'filepath' ] ) filetypes = request_data[ 'file_data' ][ filepath ][ 'filetypes' ] @@ -67,7 +67,7 @@ class FilenameCompleter( Completer ): def ShouldUseNowInner( self, request_data ): - start_column = request_data[ 'start_column' ] + start_column = request_data[ 'start_column' ] - 1 current_line = request_data[ 'line_value' ] return ( start_column and ( current_line[ start_column - 1 ] == '/' or self.AtIncludeStatementStart( request_data ) ) ) @@ -79,7 +79,7 @@ class FilenameCompleter( Completer ): def ComputeCandidatesInner( self, request_data ): current_line = request_data[ 'line_value' ] - start_column = request_data[ 'start_column' ] + start_column = request_data[ 'start_column' ] - 1 filepath = ToUtf8IfNeeded( request_data[ 'filepath' ] ) filetypes = request_data[ 'file_data' ][ filepath ][ 'filetypes' ] line = current_line[ :start_column ] diff --git a/python/ycm/completers/general/tests/filename_completer_test.py b/python/ycm/completers/general/tests/filename_completer_test.py index bebdad3b..28f236c8 100644 --- a/python/ycm/completers/general/tests/filename_completer_test.py +++ b/python/ycm/completers/general/tests/filename_completer_test.py @@ -40,7 +40,7 @@ request_data = { } def GetCompletionData( request_data ): - request_data[ 'start_column' ] = len( request_data[ 'line_value' ] ) + request_data[ 'start_column' ] = len( request_data[ 'line_value' ] ) + 1 candidates = fnc.ComputeCandidatesInner( request_data ) return [ ( c[ 'insertion_text' ], c[ 'extra_menu_info' ] ) for c in candidates ] diff --git a/python/ycm/completers/python/jedi_completer.py b/python/ycm/completers/python/jedi_completer.py index b7f61a61..283106b9 100644 --- a/python/ycm/completers/python/jedi_completer.py +++ b/python/ycm/completers/python/jedi_completer.py @@ -48,9 +48,9 @@ class JediCompleter( Completer ): def _GetJediScript( self, request_data ): filename = request_data[ 'filepath' ] contents = request_data[ 'file_data' ][ filename ][ 'contents' ] - # Jedi expects lines to start at 1, not 0 - line = request_data[ 'line_num' ] + 1 - column = request_data[ 'column_num' ] + line = request_data[ 'line_num' ] + # Jedi expects columns to start at 0, not 1 + column = request_data[ 'column_num' ] - 1 return jedi.Script( contents, line, column, filename ) @@ -134,8 +134,8 @@ class JediCompleter( Completer ): raise RuntimeError( 'Builtin modules cannot be displayed.' ) else: return responses.BuildGoToResponse( definition.module_path, - definition.line - 1, - definition.column ) + definition.line, + definition.column + 1 ) else: # multiple definitions defs = [] @@ -146,8 +146,8 @@ class JediCompleter( Completer ): else: defs.append( responses.BuildGoToResponse( definition.module_path, - definition.line - 1, - definition.column, + definition.line, + definition.column + 1, definition.description ) ) return defs diff --git a/python/ycm/diagnostic_interface.py b/python/ycm/diagnostic_interface.py index 8e5b7fbb..3cbc2181 100644 --- a/python/ycm/diagnostic_interface.py +++ b/python/ycm/diagnostic_interface.py @@ -83,22 +83,22 @@ def _UpdateSquiggles( buffer_number_to_line_to_diags ): if location_extent[ 'start' ][ 'line_num' ] < 0: location = diag[ 'location' ] vimsupport.AddDiagnosticSyntaxMatch( - location[ 'line_num' ] + 1, - location[ 'column_num' ] + 1 ) + location[ 'line_num' ], + location[ 'column_num' ] ) else: vimsupport.AddDiagnosticSyntaxMatch( - location_extent[ 'start' ][ 'line_num' ] + 1, - location_extent[ 'start' ][ 'column_num' ] + 1, - location_extent[ 'end' ][ 'line_num' ] + 1, - location_extent[ 'end' ][ 'column_num' ] + 1, + location_extent[ 'start' ][ 'line_num' ], + location_extent[ 'start' ][ 'column_num' ], + location_extent[ 'end' ][ 'line_num' ], + location_extent[ 'end' ][ 'column_num' ], is_error = is_error ) for diag_range in diag[ 'ranges' ]: vimsupport.AddDiagnosticSyntaxMatch( - diag_range[ 'start' ][ 'line_num' ] + 1, - diag_range[ 'start' ][ 'column_num' ] + 1, - diag_range[ 'end' ][ 'line_num' ] + 1, - diag_range[ 'end' ][ 'column_num' ] + 1, + diag_range[ 'start' ][ 'line_num' ], + diag_range[ 'start' ][ 'column_num' ], + diag_range[ 'end' ][ 'line_num' ], + diag_range[ 'end' ][ 'column_num' ], is_error = is_error ) @@ -125,7 +125,7 @@ def _ConvertDiagListToDict( diag_list ): location = diag[ 'location' ] buffer_number = vimsupport.GetBufferNumberForFilename( location[ 'filepath' ] ) - line_number = location[ 'line_num' ] + 1 + line_number = location[ 'line_num' ] buffer_to_line_to_diags[ buffer_number ][ line_number ].append( diag ) for line_to_diags in buffer_to_line_to_diags.itervalues(): diff --git a/python/ycm/server/responses.py b/python/ycm/server/responses.py index acd1f8cc..966eb13b 100644 --- a/python/ycm/server/responses.py +++ b/python/ycm/server/responses.py @@ -110,8 +110,8 @@ def BuildDiagnosticData( diagnostic ): def BuildLocationData( location ): return { - 'line_num': location.line_number_ - 1, - 'column_num': location.column_number_ - 1, + 'line_num': location.line_number_, + 'column_num': location.column_number_, 'filepath': location.filename_, } diff --git a/python/ycm/server/tests/diagnostics_test.py b/python/ycm/server/tests/diagnostics_test.py index 6f9d901d..ec67a41c 100644 --- a/python/ycm/server/tests/diagnostics_test.py +++ b/python/ycm/server/tests/diagnostics_test.py @@ -55,26 +55,26 @@ void foo() { 'text': contains_string( 'cannot initialize' ), 'ranges': contains( has_entries( { 'start': has_entries( { - 'line_num': 2, - 'column_num': 15, + 'line_num': 3, + 'column_num': 16, } ), 'end': has_entries( { - 'line_num': 2, - 'column_num': 20, + 'line_num': 3, + 'column_num': 21, } ), } ) ), 'location': has_entries( { - 'line_num': 2, - 'column_num': 9 + 'line_num': 3, + 'column_num': 10 } ), 'location_extent': has_entries( { 'start': has_entries( { - 'line_num': 2, - 'column_num': 9, + 'line_num': 3, + 'column_num': 10, } ), 'end': has_entries( { - 'line_num': 2, - 'column_num': 12, + 'line_num': 3, + 'column_num': 13, } ), } ) } ) ) ) @@ -102,12 +102,12 @@ void foo() { has_entries( { 'location_extent': has_entries( { 'start': has_entries( { - 'line_num': 2, - 'column_num': 2, + 'line_num': 3, + 'column_num': 3, } ), 'end': has_entries( { - 'line_num': 2, - 'column_num': 5, + 'line_num': 3, + 'column_num': 6, } ), } ) } ) ) ) @@ -163,17 +163,17 @@ def Diagnostics_CsCompleter_ZeroBasedLineAndColumn_test(): 'text': contains_string( "Unexpected symbol `}'', expecting identifier" ), 'location': has_entries( { - 'line_num': 9, - 'column_num': 1 + 'line_num': 10, + 'column_num': 2 } ), 'location_extent': has_entries( { 'start': has_entries( { - 'line_num': 9, - 'column_num': 1, + 'line_num': 10, + 'column_num': 2, } ), 'end': has_entries( { - 'line_num': 9, - 'column_num': 1, + 'line_num': 10, + 'column_num': 2, } ), } ) } ) ) ) @@ -194,7 +194,7 @@ struct Foo { """ diag_data = BuildRequest( compilation_flags = ['-x', 'c++'], - line_num = 2, + line_num = 3, contents = contents, filetype = 'cpp' ) @@ -226,9 +226,9 @@ def GetDetailedDiagnostic_CsCompleter_Works_test(): diag_data = BuildRequest( filepath = filepath, filetype = 'cs', contents = contents, - line_num = 9, - column_num = 1, - start_column = 1 ) + line_num = 10, + column_num = 2, + start_column = 2 ) results = app.post_json( '/detailed_diagnostic', diag_data ).json assert_that( results, @@ -244,7 +244,7 @@ def GetDetailedDiagnostic_CsCompleter_Works_test(): def GetDetailedDiagnostic_JediCompleter_DoesntWork_test(): app = TestApp( handlers.app ) diag_data = BuildRequest( contents = "foo = 5", - line_num = 1, + line_num = 2, filetype = 'python' ) response = app.post_json( '/detailed_diagnostic', diag_data, diff --git a/python/ycm/server/tests/get_completions_test.py b/python/ycm/server/tests/get_completions_test.py index 0e8d6a98..bcfc6976 100644 --- a/python/ycm/server/tests/get_completions_test.py +++ b/python/ycm/server/tests/get_completions_test.py @@ -50,7 +50,7 @@ def GetCompletions_IdentifierCompleter_Works_test(): completion_data = BuildRequest( contents = 'oo foo foogoo ba', query = 'oo', - column_num = 2 ) + column_num = 3 ) eq_( [ BuildCompletionData( 'foo' ), BuildCompletionData( 'foogoo' ) ], @@ -73,9 +73,9 @@ def GetCompletions_CsCompleter_Works_test(): completion_data = BuildRequest( filepath = filepath, filetype = 'cs', contents = contents, - line_num = 8, - column_num = 11, - start_column = 11 ) + line_num = 9, + column_num = 12, + start_column = 12 ) results = app.post_json( '/completions', completion_data ).json assert_that( results, has_items( CompletionEntryMatcher( 'CursorLeft' ), @@ -172,9 +172,9 @@ int main() completion_data = BuildRequest( filepath = '/foo.cpp', filetype = 'cpp', contents = contents, - line_num = 10, - column_num = 6, - start_column = 6, + line_num = 11, + column_num = 7, + start_column = 7, compilation_flags = ['-x', 'c++'] ) results = app.post_json( '/completions', completion_data ).json @@ -204,9 +204,9 @@ int main() completion_data = BuildRequest( filepath = '/foo.cpp', filetype = 'cpp', contents = contents, - line_num = 10, - column_num = 6, - start_column = 6, + line_num = 11, + column_num = 7, + start_column = 7, compilation_flags = ['-x', 'c++'] ) results = app.post_json( '/completions', completion_data ).json @@ -220,9 +220,9 @@ def GetCompletions_ClangCompleter_UnknownExtraConfException_test(): completion_data = BuildRequest( filepath = filepath, filetype = 'cpp', contents = open( filepath ).read(), - line_num = 10, - column_num = 6, - start_column = 6, + line_num = 11, + column_num = 7, + start_column = 7, force_semantic = True ) response = app.post_json( '/completions', @@ -257,9 +257,9 @@ def GetCompletions_ClangCompleter_WorksWhenExtraConfExplicitlyAllowed_test(): completion_data = BuildRequest( filepath = filepath, filetype = 'cpp', contents = open( filepath ).read(), - line_num = 10, - column_num = 6, - start_column = 6 ) + line_num = 11, + column_num = 7, + start_column = 7 ) results = app.post_json( '/completions', completion_data ).json assert_that( results, has_items( CompletionEntryMatcher( 'c' ), @@ -278,9 +278,9 @@ def GetCompletions_ClangCompleter_ExceptionWhenNoFlagsFromExtraConf_test(): completion_data = BuildRequest( filepath = filepath, filetype = 'cpp', contents = open( filepath ).read(), - line_num = 10, - column_num = 6, - start_column = 6 ) + line_num = 11, + column_num = 7, + start_column = 7 ) response = app.post_json( '/completions', completion_data, @@ -311,9 +311,9 @@ int main() filetype = 'cpp', force_semantic = True, contents = contents, - line_num = 8, - column_num = 7, - start_column = 7, + line_num = 9, + column_num = 8, + start_column = 8, query = 'fooar', compilation_flags = ['-x', 'c++'] ) @@ -347,9 +347,9 @@ def GetCompletions_ClangCompleter_ClientDataGivenToExtraConf_test(): completion_data = BuildRequest( filepath = filepath, filetype = 'cpp', contents = open( filepath ).read(), - line_num = 8, - column_num = 6, - start_column = 6, + line_num = 9, + column_num = 7, + start_column = 7, extra_conf_data = { 'flags': ['-x', 'c++'] }) @@ -368,7 +368,7 @@ def GetCompletions_IdentifierCompleter_SyntaxKeywordsAdded_test(): completion_data = BuildRequest( contents = 'oo ', query = 'oo', - column_num = 2 ) + column_num = 3 ) eq_( [ BuildCompletionData( 'foo' ), BuildCompletionData( 'zoo' ) ], @@ -389,7 +389,7 @@ def GetCompletions_UltiSnipsCompleter_Works_test(): completion_data = BuildRequest( contents = 'oo ', query = 'oo', - column_num = 2 ) + column_num = 3 ) eq_( [ BuildCompletionData( 'foo', ' bar' ), BuildCompletionData( 'zoo', ' goo' ) ], @@ -412,7 +412,7 @@ def GetCompletions_UltiSnipsCompleter_UnusedWhenOffWithOption_test(): completion_data = BuildRequest( contents = 'oo ', query = 'oo', - column_num = 2 ) + column_num = 3 ) eq_( [], app.post_json( '/completions', completion_data ).json ) diff --git a/python/ycm/server/tests/subcommands_test.py b/python/ycm/server/tests/subcommands_test.py index 9da31b0b..5d998fcf 100644 --- a/python/ycm/server/tests/subcommands_test.py +++ b/python/ycm/server/tests/subcommands_test.py @@ -40,16 +40,15 @@ foo() goto_data = BuildRequest( completer_target = 'filetype_default', command_arguments = ['GoToDefinition'], - line_num = 4, + line_num = 5, contents = contents, filetype = 'python', filepath = '/foo.py' ) - # 0-based line and column! eq_( { 'filepath': '/foo.py', - 'line_num': 1, - 'column_num': 4 + 'line_num': 2, + 'column_num': 5 }, app.post_json( '/run_completer_command', goto_data ).json ) @@ -74,16 +73,15 @@ int main() goto_data = BuildRequest( completer_target = 'filetype_default', command_arguments = ['GoToDefinition'], compilation_flags = ['-x', 'c++'], - line_num = 9, - column_num = 2, + line_num = 10, + column_num = 3, contents = contents, filetype = 'cpp' ) - # 0-based line and column! eq_( { 'filepath': '/foo', - 'line_num': 1, - 'column_num': 7 + 'line_num': 2, + 'column_num': 8 }, app.post_json( '/run_completer_command', goto_data ).json ) diff --git a/python/ycm/server/tests/test_utils.py b/python/ycm/server/tests/test_utils.py index 676e6842..0d09ddcb 100644 --- a/python/ycm/server/tests/test_utils.py +++ b/python/ycm/server/tests/test_utils.py @@ -29,9 +29,9 @@ def BuildRequest( **kwargs ): request = { 'query': '', - 'line_num': 0, - 'column_num': 0, - 'start_column': 0, + 'line_num': 1, + 'column_num': 1, + 'start_column': 1, 'filetypes': [ filetype ], 'filepath': filepath, 'line_value': contents, @@ -51,8 +51,8 @@ def BuildRequest( **kwargs ): if key == 'line_num': lines = contents.splitlines() if len( lines ) > 1: - # NOTE: assumes 0-based line_num - request[ 'line_value' ] = lines[ value ] + # NOTE: assumes 1-based line_num + request[ 'line_value' ] = lines[ value - 1 ] return request