Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

craziness continues

  • Loading branch information...
commit d6151cd45ed5a031e96942c5c3935e2924f056ec 1 parent fa87e8d
@xeno-by authored
View
30 Packages/BufferScroll/BufferScroll.py
@@ -30,18 +30,26 @@ def on_load(self, view):
self.restore(view)
sublime.set_timeout(lambda: self.restoreScroll(view), 200)
- # xeno.by: very stupid, yes, but that's the only way to keep position
- # after the file has been reloading because of external modifications
+ # xeno.by: very stupid, yes, but that's the only way to keep the position
+ # after the file has been reloaded because of external modifications
def on_activated(self, view):
- if view.file_name() != None and view.file_name() != '':
- if unlock():
- print("buffer_scroll: on_activated locked")
- return
- else:
- print("buffer_scroll: on_activated unlocked")
-
- self.restore(view)
- sublime.set_timeout(lambda: self.restoreScroll(view), 200)
+ skip = hasattr(self, "last_activated") and not filter(lambda view: view.id() == self.last_activated, view.window().views())
+ self.last_activated = view.id()
+
+ # xeno.by: we need to filter out on_activate after an overlay is closed
+ # otherwise, ctrl+f becomes unusable, and so becomes ctrl+g
+ if not skip:
+ if view.file_name() != None and view.file_name() != '':
+ if unlock():
+ print("buffer_scroll: on_activated locked")
+ return
+ else:
+ print("buffer_scroll: on_activated unlocked")
+
+ self.restore(view)
+ sublime.set_timeout(lambda: self.restoreScroll(view), 200)
+ else:
+ print("buffer_scroll: on_activated after quitting an overlay, skipped")
# the application is not sending "on_close" event when closing
# or switching the projects, then we need to save the data on focus lost
View
4 Packages/Default/Default (Linux).sublime-keymap
@@ -224,8 +224,8 @@
{ "keys": ["ctrl+e"], "command": "slurp_find_string" },
{ "keys": ["ctrl+shift+e"], "command": "slurp_replace_string" },
{ "keys": ["ctrl+shift+f"], "command": "show_panel", "args": {"panel": "find_in_files"} },
- { "keys": ["f4"], "command": "next_result" },
- { "keys": ["shift+f4"], "command": "prev_result" },
+ { "keys": ["f4"], "command": "buffer_scroll_friendly_next_result" },
+ { "keys": ["shift+f4"], "command": "buffer_scroll_friendly_prev_result" },
{ "keys": ["f6"], "command": "toggle_setting", "args": {"setting": "spell_check"} },
{ "keys": ["ctrl+f6"], "command": "next_misspelling" },
View
4 Packages/Default/Default (OSX).sublime-keymap
@@ -188,8 +188,8 @@ and don't need to be repeated here. Anything listed here will take precedence, h
{ "keys": ["ctrl+super+g"], "command": "find_all_under" },
{ "keys": ["super+shift+f"], "command": "show_panel", "args": {"panel": "find_in_files"} },
- { "keys": ["f4"], "command": "next_result" },
- { "keys": ["shift+f4"], "command": "prev_result" },
+ { "keys": ["f4"], "command": "buffer_scroll_friendly_next_result" },
+ { "keys": ["shift+f4"], "command": "buffer_scroll_friendly_prev_result" },
{ "keys": ["f6"], "command": "toggle_setting", "args": {"setting": "spell_check"} },
{ "keys": ["ctrl+f6"], "command": "next_misspelling" },
View
4 Packages/Default/Default (Windows).sublime-keymap
@@ -221,8 +221,8 @@
{ "keys": ["ctrl+e"], "command": "slurp_find_string" },
{ "keys": ["ctrl+shift+e"], "command": "slurp_replace_string" },
{ "keys": ["ctrl+shift+f"], "command": "show_panel", "args": {"panel": "find_in_files"} },
- { "keys": ["f4"], "command": "next_result" },
- { "keys": ["shift+f4"], "command": "prev_result" },
+ { "keys": ["f4"], "command": "buffer_scroll_friendly_next_result" },
+ { "keys": ["shift+f4"], "command": "buffer_scroll_friendly_prev_result" },
{ "keys": ["f6"], "command": "toggle_setting", "args": {"setting": "spell_check"} },
{ "keys": ["ctrl+f6"], "command": "next_misspelling" },
View
8 Packages/Default/Main.sublime-menu
@@ -300,8 +300,8 @@
"children":
[
{ "command": "show_panel", "args": {"panel": "output.find_results"}, "caption": "Show Results Panel" },
- { "command": "next_result" },
- { "command": "prev_result", "caption": "Previous Result" }
+ { "command": "buffer_scroll_friendly_next_result" },
+ { "command": "buffer_scroll_friendly_prev_result", "caption": "Previous Result" }
]
}
]
@@ -628,8 +628,8 @@
"children":
[
{ "command": "show_panel", "args": {"panel": "output.exec"}, "caption": "Show Build Results", "mnemonic": "S" },
- { "command": "next_result", "mnemonic": "N" },
- { "command": "prev_result", "caption": "Previous Result", "mnemonic": "P" }
+ { "command": "buffer_scroll_friendly_next_result", "mnemonic": "N" },
+ { "command": "buffer_scroll_friendly_prev_result", "caption": "Previous Result", "mnemonic": "P" }
]
},
{ "command": "toggle_save_all_on_build", "caption": "Save All on Build", "mnemonic": "A", "checkbox": true },
View
2  Packages/EnterToJumpToResult/enterToJumpToResult.py
@@ -15,4 +15,4 @@ def run(self):
view.sel().clear()
view.sel().add(sublime.Region(pt))
view.show(pt)
- self.window.run_command("next_result")
+ self.window.run_command("buffer_scroll_friendly_next_result")
View
28 Packages/NavigationHistory/navigationHistory.py
@@ -58,10 +58,9 @@ def record_movement(self, location):
if self._current:
time_delta = abs(location.time - self._current.time)
- print("time delta is: " + str(time_delta))
subsume = self._current.path == location.path and time_delta <= TIME_THRESHOLD
if subsume:
- print("nav_history: subsumed current")
+ print("nav_history: subsumed current, time delta is " + str(time_delta))
if self.has_changed(location):
self._current = location
self._last_movement = location.copy()
@@ -151,14 +150,35 @@ def get_history():
_histories[window_id] = history = History()
return history
+class PrintNavigationHistory(sublime_plugin.WindowCommand):
+ def run(self):
+ history = get_history()
+ if history is None:
+ return
+
+ print("=====")
+ for entry in history._back:
+ print(str(entry.path) + ":" + str(entry.line) + ":" + str(entry.col))
+ print("* " + str(history._current.path) + ":" + str(history._current.line) + ":" + str(history._current.col))
+ for entry in history._forward:
+ print(str(entry.path) + ":" + str(entry.line) + ":" + str(entry.col))
+ print("=====")
+
class NavigationHistoryRecorder(sublime_plugin.EventListener):
"""Keep track of history
"""
def on_selection_modified(self, view):
+ # filters out temporary navs from ctrl+f and ctrl+g
+ active_view_id = view.window() and view.window().active_view() and view.window().active_view().id()
+ if hasattr(self, "_last_activated") and self._last_activated and self._last_activated != active_view_id:
+ print("nav_history: on_selection_modified when an overlay is active, skipped")
+ return
+
self.possiblyRecordMovement(view)
def on_activated(self, view):
+ self._last_activated = view.id()
self.possiblyRecordMovement(view)
def possiblyRecordMovement(self, view):
@@ -211,6 +231,7 @@ def run(self, edit):
location = history.back()
if location:
+ lock_buffer_scroll()
print("back to: " + str(location.path) + ":" + str(location.line) + ":" + str(location.col))
window = sublime.active_window()
@@ -221,7 +242,6 @@ def run(self, edit):
for view in window.views():
if view.id() == location.path:
found = True
- lock_buffer_scroll()
window.focus_view(view)
pt = view.text_point(location.line, location.col)
view.sel().clear()
@@ -243,6 +263,7 @@ def run(self, edit):
location = history.forward()
if location:
+ lock_buffer_scroll()
print("forward to: " + str(location.path) + ":" + str(location.line) + ":" + str(location.col))
window = sublime.active_window()
@@ -253,7 +274,6 @@ def run(self, edit):
for view in window.views():
if view.id() == location.path:
found = True
- lock_buffer_scroll()
window.focus_view(view)
pt = view.text_point(location.line, location.col)
view.sel().clear()
View
2  Packages/User/Package Control.sublime-settings
@@ -1,5 +1,5 @@
{
- "auto_upgrade_last_run": 1327962613,
+ "auto_upgrade_last_run": 1328090570,
"installed_packages":
[
"BufferScroll",
Please sign in to comment.
Something went wrong with that request. Please try again.