Exemple #1
0
def diff(left, right, external=False):
    """
    Initiate diff by getting left side and right side compare.

    Call the appropriate diff method and call internal or external diff.
    """

    lw = None
    rw = None
    lv = None
    rv = None

    for w in sublime.windows():
        if w.id() == left["win_id"]:
            lw = w
        if w.id() == right["win_id"]:
            rw = w
        if lw is not None and rw is not None:
            break

    if lw is not None:
        for v in lw.views():
            if v.id() == left["view_id"]:
                lv = v
                break
    else:
        if left["clip"]:
            lv = left["clip"]

    if rw is not None:
        for v in rw.views():
            if v.id() == right["view_id"]:
                rv = v
                break
    else:
        if right["clip"]:
            rv = right["clip"]

    if lv is not None and rv is not None:
        ext_diff = get_external_diff()
        if external:
            EasyDiff.extcompare(EasyDiffInput(lv, rv, external=True), ext_diff)
        else:
            EasyDiff.compare(EasyDiffInput(lv, rv))
    else:
        log("Can't compare")
def diff(left, right, external=False):
    """
    Initiate diff by getting left side and right side compare.

    Call the appropriate diff method and call internal or external diff.
    """

    lw = None
    rw = None
    lv = None
    rv = None

    for w in sublime.windows():
        if w.id() == left["win_id"]:
            lw = w
        if w.id() == right["win_id"]:
            rw = w
        if lw is not None and rw is not None:
            break

    if lw is not None:
        for v in lw.views():
            if v.id() == left["view_id"]:
                lv = v
                break
    else:
        if left["clip"]:
            lv = left["clip"]

    if rw is not None:
        for v in rw.views():
            if v.id() == right["view_id"]:
                rv = v
                break
    else:
        if right["clip"]:
            rv = right["clip"]

    if lv is not None and rv is not None:
        ext_diff = get_external_diff()
        if external:
            EasyDiff.extcompare(EasyDiffInput(lv, rv, external=True), ext_diff)
        else:
            EasyDiff.compare(EasyDiffInput(lv, rv))
    else:
        log("Can't compare")
    def run(self, edit, external=False):
        self.set_right()

        lw = None
        rw = None
        lv = None
        rv = None

        for w in sublime.windows():
            if w.id() == LEFT["win_id"]:
                lw = w
            if w.id() == self.right["win_id"]:
                rw = w
            if lw is not None and rw is not None:
                break

        if lw is not None:
            for v in lw.views():
                if v.id() == LEFT["view_id"]:
                    lv = v
                    break
        else:
            if LEFT["clip"]:
                lv = LEFT["clip"]

        if rw is not None:
            for v in rw.views():
                if v.id() == self.right["view_id"]:
                    rv = v
                    break
        else:
            if self.right["clip"]:
                rv = self.right["clip"]

        if lv is not None and rv is not None:
            ext_diff = get_external_diff()
            if external:
                EasyDiff.extcompare(EasyDiffInput(lv, rv, external=True),
                                    ext_diff)
            else:
                EasyDiff.compare(EasyDiffInput(lv, rv))
        else:
            log("Can't compare")
    def run(self, edit, external=False):
        self.set_right()

        lw = None
        rw = None
        lv = None
        rv = None

        for w in sublime.windows():
            if w.id() == LEFT["win_id"]:
                lw = w
            if w.id() == self.right["win_id"]:
                rw = w
            if lw is not None and rw is not None:
                break

        if lw is not None:
            for v in lw.views():
                if v.id() == LEFT["view_id"]:
                    lv = v
                    break
        else:
            if LEFT["clip"]:
                lv = LEFT["clip"]

        if rw is not None:
            for v in rw.views():
                if v.id() == self.right["view_id"]:
                    rv = v
                    break
        else:
            if self.right["clip"]:
                rv = self.right["clip"]

        if lv is not None and rv is not None:
            ext_diff = get_external_diff()
            if external:
                EasyDiff.extcompare(EasyDiffInput(lv, rv, external=True), ext_diff)
            else:
                EasyDiff.compare(EasyDiffInput(lv, rv))
        else:
            log("Can't compare")