Skip to content

Commit d6151cd

Browse files
committed
craziness continues
1 parent fa87e8d commit d6151cd

File tree

8 files changed

+55
-27
lines changed

8 files changed

+55
-27
lines changed

Packages/BufferScroll/BufferScroll.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,26 @@ def on_load(self, view):
3030
self.restore(view)
3131
sublime.set_timeout(lambda: self.restoreScroll(view), 200)
3232

33-
# xeno.by: very stupid, yes, but that's the only way to keep position
34-
# after the file has been reloading because of external modifications
33+
# xeno.by: very stupid, yes, but that's the only way to keep the position
34+
# after the file has been reloaded because of external modifications
3535
def on_activated(self, view):
36-
if view.file_name() != None and view.file_name() != '':
37-
if unlock():
38-
print("buffer_scroll: on_activated locked")
39-
return
40-
else:
41-
print("buffer_scroll: on_activated unlocked")
42-
43-
self.restore(view)
44-
sublime.set_timeout(lambda: self.restoreScroll(view), 200)
36+
skip = hasattr(self, "last_activated") and not filter(lambda view: view.id() == self.last_activated, view.window().views())
37+
self.last_activated = view.id()
38+
39+
# xeno.by: we need to filter out on_activate after an overlay is closed
40+
# otherwise, ctrl+f becomes unusable, and so becomes ctrl+g
41+
if not skip:
42+
if view.file_name() != None and view.file_name() != '':
43+
if unlock():
44+
print("buffer_scroll: on_activated locked")
45+
return
46+
else:
47+
print("buffer_scroll: on_activated unlocked")
48+
49+
self.restore(view)
50+
sublime.set_timeout(lambda: self.restoreScroll(view), 200)
51+
else:
52+
print("buffer_scroll: on_activated after quitting an overlay, skipped")
4553

4654
# the application is not sending "on_close" event when closing
4755
# or switching the projects, then we need to save the data on focus lost

Packages/Default/Default (Linux).sublime-keymap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@
224224
{ "keys": ["ctrl+e"], "command": "slurp_find_string" },
225225
{ "keys": ["ctrl+shift+e"], "command": "slurp_replace_string" },
226226
{ "keys": ["ctrl+shift+f"], "command": "show_panel", "args": {"panel": "find_in_files"} },
227-
{ "keys": ["f4"], "command": "next_result" },
228-
{ "keys": ["shift+f4"], "command": "prev_result" },
227+
{ "keys": ["f4"], "command": "buffer_scroll_friendly_next_result" },
228+
{ "keys": ["shift+f4"], "command": "buffer_scroll_friendly_prev_result" },
229229

230230
{ "keys": ["f6"], "command": "toggle_setting", "args": {"setting": "spell_check"} },
231231
{ "keys": ["ctrl+f6"], "command": "next_misspelling" },

Packages/Default/Default (OSX).sublime-keymap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ and don't need to be repeated here. Anything listed here will take precedence, h
188188
{ "keys": ["ctrl+super+g"], "command": "find_all_under" },
189189

190190
{ "keys": ["super+shift+f"], "command": "show_panel", "args": {"panel": "find_in_files"} },
191-
{ "keys": ["f4"], "command": "next_result" },
192-
{ "keys": ["shift+f4"], "command": "prev_result" },
191+
{ "keys": ["f4"], "command": "buffer_scroll_friendly_next_result" },
192+
{ "keys": ["shift+f4"], "command": "buffer_scroll_friendly_prev_result" },
193193

194194
{ "keys": ["f6"], "command": "toggle_setting", "args": {"setting": "spell_check"} },
195195
{ "keys": ["ctrl+f6"], "command": "next_misspelling" },

Packages/Default/Default (Windows).sublime-keymap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@
221221
{ "keys": ["ctrl+e"], "command": "slurp_find_string" },
222222
{ "keys": ["ctrl+shift+e"], "command": "slurp_replace_string" },
223223
{ "keys": ["ctrl+shift+f"], "command": "show_panel", "args": {"panel": "find_in_files"} },
224-
{ "keys": ["f4"], "command": "next_result" },
225-
{ "keys": ["shift+f4"], "command": "prev_result" },
224+
{ "keys": ["f4"], "command": "buffer_scroll_friendly_next_result" },
225+
{ "keys": ["shift+f4"], "command": "buffer_scroll_friendly_prev_result" },
226226

227227
{ "keys": ["f6"], "command": "toggle_setting", "args": {"setting": "spell_check"} },
228228
{ "keys": ["ctrl+f6"], "command": "next_misspelling" },

Packages/Default/Main.sublime-menu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@
300300
"children":
301301
[
302302
{ "command": "show_panel", "args": {"panel": "output.find_results"}, "caption": "Show Results Panel" },
303-
{ "command": "next_result" },
304-
{ "command": "prev_result", "caption": "Previous Result" }
303+
{ "command": "buffer_scroll_friendly_next_result" },
304+
{ "command": "buffer_scroll_friendly_prev_result", "caption": "Previous Result" }
305305
]
306306
}
307307
]
@@ -628,8 +628,8 @@
628628
"children":
629629
[
630630
{ "command": "show_panel", "args": {"panel": "output.exec"}, "caption": "Show Build Results", "mnemonic": "S" },
631-
{ "command": "next_result", "mnemonic": "N" },
632-
{ "command": "prev_result", "caption": "Previous Result", "mnemonic": "P" }
631+
{ "command": "buffer_scroll_friendly_next_result", "mnemonic": "N" },
632+
{ "command": "buffer_scroll_friendly_prev_result", "caption": "Previous Result", "mnemonic": "P" }
633633
]
634634
},
635635
{ "command": "toggle_save_all_on_build", "caption": "Save All on Build", "mnemonic": "A", "checkbox": true },

Packages/EnterToJumpToResult/enterToJumpToResult.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ def run(self):
1515
view.sel().clear()
1616
view.sel().add(sublime.Region(pt))
1717
view.show(pt)
18-
self.window.run_command("next_result")
18+
self.window.run_command("buffer_scroll_friendly_next_result")

Packages/NavigationHistory/navigationHistory.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ def record_movement(self, location):
5858

5959
if self._current:
6060
time_delta = abs(location.time - self._current.time)
61-
print("time delta is: " + str(time_delta))
6261
subsume = self._current.path == location.path and time_delta <= TIME_THRESHOLD
6362
if subsume:
64-
print("nav_history: subsumed current")
63+
print("nav_history: subsumed current, time delta is " + str(time_delta))
6564
if self.has_changed(location):
6665
self._current = location
6766
self._last_movement = location.copy()
@@ -151,14 +150,35 @@ def get_history():
151150
_histories[window_id] = history = History()
152151
return history
153152

153+
class PrintNavigationHistory(sublime_plugin.WindowCommand):
154+
def run(self):
155+
history = get_history()
156+
if history is None:
157+
return
158+
159+
print("=====")
160+
for entry in history._back:
161+
print(str(entry.path) + ":" + str(entry.line) + ":" + str(entry.col))
162+
print("* " + str(history._current.path) + ":" + str(history._current.line) + ":" + str(history._current.col))
163+
for entry in history._forward:
164+
print(str(entry.path) + ":" + str(entry.line) + ":" + str(entry.col))
165+
print("=====")
166+
154167
class NavigationHistoryRecorder(sublime_plugin.EventListener):
155168
"""Keep track of history
156169
"""
157170

158171
def on_selection_modified(self, view):
172+
# filters out temporary navs from ctrl+f and ctrl+g
173+
active_view_id = view.window() and view.window().active_view() and view.window().active_view().id()
174+
if hasattr(self, "_last_activated") and self._last_activated and self._last_activated != active_view_id:
175+
print("nav_history: on_selection_modified when an overlay is active, skipped")
176+
return
177+
159178
self.possiblyRecordMovement(view)
160179

161180
def on_activated(self, view):
181+
self._last_activated = view.id()
162182
self.possiblyRecordMovement(view)
163183

164184
def possiblyRecordMovement(self, view):
@@ -211,6 +231,7 @@ def run(self, edit):
211231

212232
location = history.back()
213233
if location:
234+
lock_buffer_scroll()
214235
print("back to: " + str(location.path) + ":" + str(location.line) + ":" + str(location.col))
215236

216237
window = sublime.active_window()
@@ -221,7 +242,6 @@ def run(self, edit):
221242
for view in window.views():
222243
if view.id() == location.path:
223244
found = True
224-
lock_buffer_scroll()
225245
window.focus_view(view)
226246
pt = view.text_point(location.line, location.col)
227247
view.sel().clear()
@@ -243,6 +263,7 @@ def run(self, edit):
243263

244264
location = history.forward()
245265
if location:
266+
lock_buffer_scroll()
246267
print("forward to: " + str(location.path) + ":" + str(location.line) + ":" + str(location.col))
247268

248269
window = sublime.active_window()
@@ -253,7 +274,6 @@ def run(self, edit):
253274
for view in window.views():
254275
if view.id() == location.path:
255276
found = True
256-
lock_buffer_scroll()
257277
window.focus_view(view)
258278
pt = view.text_point(location.line, location.col)
259279
view.sel().clear()

Packages/User/Package Control.sublime-settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"auto_upgrade_last_run": 1327962613,
2+
"auto_upgrade_last_run": 1328090570,
33
"installed_packages":
44
[
55
"BufferScroll",

0 commit comments

Comments
 (0)