<commit_before>#
# default.py
#
# Ped plugin adding a configurable shortkey to insert/remove comment char
# from the beginning of a line.
#
# Copyright (c) 2008, <NAME>
# <<EMAIL>>
#
# Distributed under the new BSD license.
#

import sys
import os
import ped
import ui

# new ped.PythonFileWindow.control_key_press method
def control_key_press(self, key):
    # check if the configured shortkey was pressed
    if key == ped.app.settings['ezcomment_key'].get():
        # move the cursor to the start of a line
        self.move_beg_of_line()
        
        # check if there are '#' chars at cursor and remove them
        # or add one if there wren't any
        pos = self.body.get_pos()
        while True:
            char = self.body.get(pos, 1)
            if char == '#':
                self.body.delete(pos, 1)
            else:
                self.body.add(u'#')
                break
        
        # find the start of next line and go there
        found = False
        for ln, lpos, line in self.get_lines():<commit_msg>Comment removal didn't work properly.<commit_after>#
# default.py
#
# Ped plugin adding a configurable shortkey to insert/remove comment char
# from the beginning of a line.
#
# Copyright (c) 2008, <NAME>
# <<EMAIL>>
#
# Distributed under the new BSD license.
#

import sys
import os
import ped
import ui

# new ped.PythonFileWindow.control_key_press method
def control_key_press(self, key):
    # check if the configured shortkey was pressed
    if key == ped.app.settings['ezcomment_key'].get():
        # move the cursor to the start of a line
        self.move_beg_of_line()
        
        # check if there are '#' chars at cursor and remove them
        # or add one if there wren't any
        pos = self.body.get_pos()
        if self.body.get(pos, 1) == u'#':
            while self.body.get(pos, 1) == u'#':
                self.body.delete(pos, 1)
        else:
            self.body.add(u'#')
        
        # find the start of next line and go there
        found = False
        for ln, lpos, line in self.get_lines():
{'fraction_non_alphanumeric': 0.09787849566055931, 'fraction_numerical': 0.00626808100289296, 'mean_word_length': 2.2270606531881803, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7122318', 'n_tokens_mistral': 643, 'n_tokens_neox': 612, 'n_words': 225}