<s> import sublime <EOL> import sublime_plugin <EOL> import json <EOL> from threading import Thread <EOL> from . . lib . ycmd_handler import server <EOL> from . . lib . utils import * <EOL> def goto_func ( server , filepath , contents , row , col , callback ) : <EOL> '''<STR_LIT>''' <EOL> rst = server . SendGoToRequest ( filepath = filepath , <EOL> contents = contents , <EOL> filetype = '<STR_LIT>' , <EOL> line_num = row , <EOL> column_num = col ) <EOL> if rst == '<STR_LIT>' : <EOL> return <EOL> data = json . loads ( rst ) <EOL> row = data . get ( '<STR_LIT>' , <NUM_LIT:1> ) - <NUM_LIT:1> <EOL> col = data . get ( '<STR_LIT>' , <NUM_LIT:1> ) - <NUM_LIT:1> <EOL> callback ( row , col ) <EOL> class CppycmGotoCommand ( sublime_plugin . TextCommand ) : <EOL> '''<STR_LIT>''' <EOL> def run ( self , edit ) : <EOL> row , col = get_row_col ( self . view ) <EOL> filepath = get_file_path ( self . view . file_name ( ) ) <EOL> contents = self . view . substr ( sublime . Region ( <NUM_LIT:0> , self . view . size ( ) ) ) <EOL> t = Thread ( None , goto_func , '<STR_LIT>' , <EOL> [ server ( ) , filepath , contents , row , col , self . _goto ] ) <EOL> t . daemon = True <EOL> t . start ( ) <EOL> def is_enabled ( self ) : <EOL> '''<STR_LIT>''' <EOL> return is_cpp ( self . view ) <EOL> def _goto ( self , row , col ) : <EOL> '''<STR_LIT>''' <EOL> point = self . view . text_point ( row , col ) <EOL> region = self . view . word ( <EOL> point ) if check_select_after_goto ( ) else sublime . Region ( point , point ) <EOL> self . view . sel ( ) . clear ( ) <EOL> self . view . sel ( ) . add ( region ) <EOL> self . view . show_at_center ( region ) </s>
