def check_operation(self, thread, previous_progress_indicator_tuple=None):
        selected_word = thread.selected_word
        if not thread.is_alive():

            # Flatten any selection ranges
            if len(self.view.sel()) > 0:
                region = self.view.sel()[0]
                debug(region)
                end_point = region.end()
                region_to_select = sublime.Region(end_point, end_point)
                coffee_utils.select_region_in_view(self.view, region_to_select)

            matched_location_tuple = thread.matched_location_tuple
            if matched_location_tuple:
                # debug("Match found!")
                file_to_open = matched_location_tuple[0]
                row = matched_location_tuple[1] + 1
                column = matched_location_tuple[2] + 1
                match = matched_location_tuple[3]
                row_start_index = matched_location_tuple[4]
                # If there is a file to open...
                if file_to_open:
                    # Open the file in the editor
                    coffee_utils.open_file_at_position(self.window, file_to_open, row, column)
                    # Otherwise, assume we found the match in the current view
                else:
                    match_end = row_start_index + match.start() + len(match.group())
                    region_to_select = sublime.Region(match_end, match_end)
                    coffee_utils.select_region_in_view(self.view, region_to_select)
                    self.view.show(region_to_select)

                self.window.active_view().set_status(COMMAND_NAME, STATUS_MESSAGE_DEFINITION_FOUND % selected_word)
            else:
                self.window.active_view().set_status(COMMAND_NAME, STATUS_MESSAGE_NO_DEFINITION_FOUND % selected_word)

        else:
            # Create the command's goto definition text, including the selected word. For the status bar.
            goto_definition_status_text = STATUS_MESSAGE_COFFEE_GOTO_DEFINITION % selected_word
            # Get a tuple containing the progress text, progress position, and progress direction.
            # This is used to animate a progress indicator in the status bar.
            current_progress_indicator_tuple = coffee_utils.get_progress_indicator_tuple(
                previous_progress_indicator_tuple
            )
            # Get the progress text
            progress_indicator_status_text = current_progress_indicator_tuple[0]
            # Set the status bar text so the user knows what's going on
            self.window.active_view().set_status(
                COMMAND_NAME, goto_definition_status_text + " " + progress_indicator_status_text
            )
            # Check again momentarily to see if the operation has completed.
            sublime.set_timeout(lambda: self.check_operation(thread, current_progress_indicator_tuple), 100)
Пример #2
0
	def check_operation(self, thread, previous_progress_indicator_tuple=None):
		selected_word = thread.selected_word
		if not thread.is_alive():

			# Flatten any selection ranges
			if len(self.view.sel()) > 0:
				region = self.view.sel()[0]
				debug(region)
				end_point = region.end()
				region_to_select = sublime.Region(end_point, end_point)
				coffee_utils.select_region_in_view(self.view, region_to_select)

			matched_location_tuple = thread.matched_location_tuple
			if matched_location_tuple:
				# debug("Match found!")
				file_to_open = matched_location_tuple[0]
				row = matched_location_tuple[1] + 1
				column = matched_location_tuple[2] + 1
				match = matched_location_tuple[3]
				row_start_index = matched_location_tuple[4]
				# If there is a file to open...
				if file_to_open:
					# Open the file in the editor
					coffee_utils.open_file_at_position(self.window, file_to_open, row, column)
				# Otherwise, assume we found the match in the current view
				else:
					match_end = row_start_index + match.start() + len(match.group())
					region_to_select = sublime.Region(match_end, match_end)
					coffee_utils.select_region_in_view(self.view, region_to_select)
					self.view.show(region_to_select)

				self.window.active_view().set_status(COMMAND_NAME, STATUS_MESSAGE_DEFINITION_FOUND % selected_word)
			else:
				self.window.active_view().set_status(COMMAND_NAME, STATUS_MESSAGE_NO_DEFINITION_FOUND % selected_word)

		else:
			# Create the command's goto definition text, including the selected word. For the status bar.
			goto_definition_status_text = STATUS_MESSAGE_COFFEE_GOTO_DEFINITION % selected_word
			# Get a tuple containing the progress text, progress position, and progress direction.
			# This is used to animate a progress indicator in the status bar.
			current_progress_indicator_tuple = coffee_utils.get_progress_indicator_tuple(previous_progress_indicator_tuple)
			# Get the progress text
			progress_indicator_status_text = current_progress_indicator_tuple[0]
			# Set the status bar text so the user knows what's going on
			self.window.active_view().set_status(COMMAND_NAME, goto_definition_status_text + " " + progress_indicator_status_text)
			# Check again momentarily to see if the operation has completed.
			sublime.set_timeout(lambda: self.check_operation(thread, current_progress_indicator_tuple), 100)
Пример #3
0
    def check_operation(self,
                        thread,
                        final_completions,
                        current_location,
                        token,
                        status,
                        previous_progress_indicator_tuple=None):

        if not thread.is_alive():
            if thread.completions:
                final_completions.extend(thread.completions)
                # Hide the default auto-complete and show ours
                self.window.active_view().run_command('hide_auto_complete')
                sublime.set_timeout(
                    lambda: self.window.active_view().run_command(
                        'auto_complete'), 1)

            self.window.active_view().erase_status(
                COFFEESCRIPT_AUTOCOMPLETE_STATUS_KEY)
            status["working"] = False
        else:
            token = thread.token
            # Create the command's goto definition text, including the selected word. For the status bar.
            status_text = COFFEESCRIPT_AUTOCOMPLETE_STATUS_MESSAGE % token
            # Get a tuple containing the progress text, progress position, and progress direction.
            # This is used to animate a progress indicator in the status bar.
            current_progress_indicator_tuple = coffee_utils.get_progress_indicator_tuple(
                previous_progress_indicator_tuple)
            # Get the progress text
            progress_indicator_status_text = current_progress_indicator_tuple[
                0]
            # Set the status bar text so the user knows what's going on
            self.window.active_view().set_status(
                COFFEESCRIPT_AUTOCOMPLETE_STATUS_KEY,
                status_text + " " + progress_indicator_status_text)
            # Check again momentarily to see if the operation has completed.
            sublime.set_timeout(
                lambda: self.check_operation(
                    thread, final_completions, current_location, token, status,
                    current_progress_indicator_tuple), 100)
	def check_operation(self, thread, final_completions, current_location, token, status, previous_progress_indicator_tuple=None):

		if not thread.is_alive():
			if thread.completions:
				final_completions.extend(thread.completions)
				# Hide the default auto-complete and show ours
				self.window.active_view().run_command('hide_auto_complete')
				sublime.set_timeout(lambda: self.window.active_view().run_command('auto_complete'), 1)

			self.window.active_view().erase_status(COFFEESCRIPT_AUTOCOMPLETE_STATUS_KEY)
			status["working"] = False
		else:
			token = thread.token
			# Create the command's goto definition text, including the selected word. For the status bar.
			status_text = COFFEESCRIPT_AUTOCOMPLETE_STATUS_MESSAGE % token
			# Get a tuple containing the progress text, progress position, and progress direction.
			# This is used to animate a progress indicator in the status bar.
			current_progress_indicator_tuple = coffee_utils.get_progress_indicator_tuple(previous_progress_indicator_tuple)
			# Get the progress text
			progress_indicator_status_text = current_progress_indicator_tuple[0]
			# Set the status bar text so the user knows what's going on
			self.window.active_view().set_status(COFFEESCRIPT_AUTOCOMPLETE_STATUS_KEY, status_text + " " + progress_indicator_status_text)
			# Check again momentarily to see if the operation has completed.
			sublime.set_timeout(lambda: self.check_operation(thread, final_completions, current_location, token, status, current_progress_indicator_tuple), 100)