gornostal / Modific

Highlight lines changed since the last commit (supports Git, SVN, Bazaar, Mercurial and TFS) / ST2(3) plugin
614 stars 44 forks source link

Limit checks to filesize #27

Closed secharly closed 12 years ago

secharly commented 12 years ago

This is a great product, however sometimes we are required to open semi large files (1MB+), this plugin seems to cause sublime to slow down. What would be great is a setting to limit checking the source control by file size. For a work around now we have change the following Under DiffCommand -> run

def run(self, edit):
        vcs = get_vcs(self.get_working_dir())
        filename = os.path.basename(self.view.file_name())
        get_command = getattr(self, '{0}_diff_command'.format(vcs['name']), None)
        if get_command:
            self.run_command(get_command(filename), self.diff_done)
def run(self, edit):
        vcs = get_vcs(self.get_working_dir())
        filename = os.path.basename(self.view.file_name())
        if self.view.size() > 200000:
            return
        get_command = getattr(self, '{0}_diff_command'.format(vcs['name']), None)
        if get_command:
            self.run_command(get_command(filename), self.diff_done)
gornostal commented 12 years ago

I will add an extra option to set the maximum file size.

secharly commented 12 years ago

First the change is great and thanks for getting it out so quickly. However there appears to be a small bug at least ib my environment). I had to change

        filename = os.path.basename(self.view.file_name())
        max_file_size = settings.get('max_file_size', 1024) * 1024
        if not os.path.exists(filename) or os.path.getsize(filename) > max_file_size:
            # skip large files
        filepath = self.view.file_name()
        filename = os.path.basename(filepath)
        max_file_size = settings.get('max_file_size', 1024) * 1024
        if not os.path.exists(filepath) or os.path.getsize(filepath) > max_file_size:
            # skip large files

As it appears it needed the full path as it was not properly finding the path to the file.

gornostal commented 12 years ago

Hm.. Okay. I will change that. Thanks for noticing.