def get_hunks_from_selection(self, selection):
        if not selection:
            return None
        # parse the diff view
        diffspec = self.parse_diff()
        lookup = self.build_lookup(diffspec)

        # find the applicable hunks
        hunks = {}
        for s in selection:
            for hunk, header in lookup:
                if s.intersects(hunk) or hunk.contains(s) or (s.begin() == self.view.size() and hunk.contains(s.begin() - 1)):
                    hunks.setdefault((header.begin(), header.end()), []).append(hunk)

        return hunks
dataset/ETHPy150Open SublimeGit/SublimeGit/sgit/diff.py/GitDiffTextCmd.get_hunks_from_selection/original