示例#1
0
    def _item_selected(self, start_line, start_column, end_line, end_column):
        """Handle when an item is selected from tree or error tab.

        :param int start_line: line where the selection starts
        :param int start_column: column where the selection starts
        :param int end_line: line where the selection ends
        :param int end_column: column where the selection ends
        """
        self.editor.setFocus()

        # remove empty line and whitespaces at the end of selection
        if end_line > start_line and end_line > 1:
            last_line_text = self.editor.text(end_line-1)
            if end_column > len(last_line_text):
                end_column = len(last_line_text) + 1
            last_line_text_selected = last_line_text[:end_column-1]
            if LineAnalyzer.is_empty(last_line_text_selected):
                end_line -= 1
                end_line_text = self.editor.text(end_line-1)
                end_column = len(end_line_text)

        # select in reversed order - move cursor to the beginning of selection
        self.editor.mark_selected(end_line, end_column, start_line, start_column)
示例#2
0
def test_is_empty(line, expected):
    assert LineAnalyzer.is_empty(line) == expected