Skip to content

Commit

Permalink
Remove JumpPrevLastModification function
Browse files Browse the repository at this point in the history
This function appears to serve little purpose. Remove it. If
needed similar functionality can be achieved using commands built
in to ST3 or other plugins for legacy ST2 applications.
  • Loading branch information
stephenfin committed Nov 27, 2013
1 parent dd63989 commit c7f4f62
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 93 deletions.
5 changes: 0 additions & 5 deletions Context.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@
"command": "jump_prev",
"args": {},
"caption": "Jump Back"
},
{
"command": "jump_prev_to_last_modification",
"args": {},
"caption": "Jump Back to Last Modification"
}
]
4 changes: 0 additions & 4 deletions Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
"command": "jump_prev",
"keys": ["ctrl+shift+comma"]
},
{
"command": "jump_prev_to_last_modification",
"keys": ["ctrl+t", "ctrl+m"]
},
{
"command": "rebuild_tags",
"keys": ["ctrl+t", "ctrl+r"]
Expand Down
2 changes: 1 addition & 1 deletion Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
]
},
{
//"argr_comment": "TODO",
//"arg_comment": "TODO",
"args": {
"type": "multi"
},
Expand Down
83 changes: 0 additions & 83 deletions ctagsplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,6 @@ def get_current_file_suffix(path):
"""JumpPrev Commands"""


def different_mod_area(f1, f2, r1, r2):
same_file = f1 == f2
same_region = abs(r1[0] - r2[0]) < 40
return not same_file or not same_region


class JumpPrev(sublime_plugin.WindowCommand):
"""Provide ``jump_back`` command.
Expand Down Expand Up @@ -503,83 +497,6 @@ def append(cls, view):
cls.buf.append((fn, sel))


class JumpPrevToLastModification(sublime_plugin.WindowCommand):
"""Provide ``jump_back_to_last_modification`` command.
Command "jumps back" to a previous modification point
This is functionality supported natively by ST3 but not by ST2. It is
therefore included for legacy purposes.
"""
mods = []

def is_enabled(self):
return len(self.mods) > 1

def is_visible(self):
return setting('show_context_menus')

def run(self):
if self.mods:
return self.lastModifications()

def lastModifications(self):
# c)urrent v)iew, r)egion and f)ile
cv = sublime.active_window().active_view()
cr = eval(repr(cv.sel()[0]))
cf = cv.file_name()

# very latest, s)tarting modification
sf, sr = JumpPrevToLastModification.mods.pop(0)

if sf is None:
return
sr = eval(sr)

in_different_mod_area = different_mod_area(sf, cf, cr, sr)

# default j)ump f)ile and r)egion
jf, jr = sf, sr

if JumpPrevToLastModification.mods:
for i, (f, r) in enumerate(JumpPrevToLastModification.mods):
region = eval(r)
if different_mod_area(sf, f, sr, region):
break

del JumpPrevToLastModification.mods[:i]
if not in_different_mod_area:
jf, jr = f, region

if in_different_mod_area or not JumpPrevToLastModification.mods:
JumpPrevToLastModification.mods.insert(0, (jf, repr(jr)))

self.jump(jf, jr)

def jump(self, fn, sel):
@on_load(fn, begin_edit=True)
def and_then(view):
select(view, sublime.Region(*sel))


class JumpPrevListener(sublime_plugin.EventListener):
"""Maintain a list of edit points to jump back to.
Maintains a list of the last x edit points (points where a character is
added, removed or modified) in order to allow the user to correctly
"jump back" to a previous point in the code.
This is functionality supported natively by ST3 but not by ST2. It is
therefore included for legacy purposes.
"""
def on_modified(self, view):
sel = view.sel()
if len(sel):
JumpPrevToLastModification.mods.insert(
0, (view.file_name(), repr(sel[0])))
del JumpPrevToLastModification.mods[100:]


"""CTags commands"""


Expand Down

0 comments on commit c7f4f62

Please sign in to comment.