Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

craziness continues

  • Loading branch information...
commit d6151cd45ed5a031e96942c5c3935e2924f056ec 1 parent fa87e8d
Eugene Burmako authored February 01, 2012
30  Packages/BufferScroll/BufferScroll.py
@@ -30,18 +30,26 @@ def on_load(self, view):
30 30
 			self.restore(view)
31 31
 			sublime.set_timeout(lambda: self.restoreScroll(view), 200)
32 32
 
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
35 35
 	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")
45 53
 
46 54
 	# the application is not sending "on_close" event when closing
47 55
 	# or switching the projects, then we need to save the data on focus lost
4  Packages/Default/Default (Linux).sublime-keymap
@@ -224,8 +224,8 @@
224 224
 	{ "keys": ["ctrl+e"], "command": "slurp_find_string" },
225 225
 	{ "keys": ["ctrl+shift+e"], "command": "slurp_replace_string" },
226 226
 	{ "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" },
229 229
 
230 230
 	{ "keys": ["f6"], "command": "toggle_setting", "args": {"setting": "spell_check"} },
231 231
 	{ "keys": ["ctrl+f6"], "command": "next_misspelling" },
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
188 188
 	{ "keys": ["ctrl+super+g"], "command": "find_all_under" },
189 189
 
190 190
 	{ "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" },
193 193
 
194 194
 	{ "keys": ["f6"], "command": "toggle_setting", "args": {"setting": "spell_check"} },
195 195
 	{ "keys": ["ctrl+f6"], "command": "next_misspelling" },
4  Packages/Default/Default (Windows).sublime-keymap
@@ -221,8 +221,8 @@
221 221
 	{ "keys": ["ctrl+e"], "command": "slurp_find_string" },
222 222
 	{ "keys": ["ctrl+shift+e"], "command": "slurp_replace_string" },
223 223
 	{ "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" },
226 226
 
227 227
 	{ "keys": ["f6"], "command": "toggle_setting", "args": {"setting": "spell_check"} },
228 228
 	{ "keys": ["ctrl+f6"], "command": "next_misspelling" },
8  Packages/Default/Main.sublime-menu
@@ -300,8 +300,8 @@
300 300
                 "children":
301 301
                 [
302 302
                     { "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" }
305 305
                 ]
306 306
             }
307 307
         ]
@@ -628,8 +628,8 @@
628 628
                 "children":
629 629
                 [
630 630
                     { "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" }
633 633
                 ]
634 634
             },
635 635
             { "command": "toggle_save_all_on_build", "caption": "Save All on Build", "mnemonic": "A", "checkbox": true },
2  Packages/EnterToJumpToResult/enterToJumpToResult.py
@@ -15,4 +15,4 @@ def run(self):
15 15
     view.sel().clear()
16 16
     view.sel().add(sublime.Region(pt))
17 17
     view.show(pt)
18  
-    self.window.run_command("next_result")
  18
+    self.window.run_command("buffer_scroll_friendly_next_result")
28  Packages/NavigationHistory/navigationHistory.py
@@ -58,10 +58,9 @@ def record_movement(self, location):
58 58
 
59 59
                 if self._current:
60 60
                     time_delta = abs(location.time - self._current.time)
61  
-                    print("time delta is: " + str(time_delta))
62 61
                     subsume = self._current.path == location.path and time_delta <= TIME_THRESHOLD
63 62
                     if subsume:
64  
-                        print("nav_history: subsumed current")
  63
+                        print("nav_history: subsumed current, time delta is " + str(time_delta))
65 64
                         if self.has_changed(location):
66 65
                             self._current = location
67 66
                             self._last_movement = location.copy()
@@ -151,14 +150,35 @@ def get_history():
151 150
         _histories[window_id] = history = History()
152 151
     return history
153 152
 
  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
+
154 167
 class NavigationHistoryRecorder(sublime_plugin.EventListener):
155 168
     """Keep track of history
156 169
     """
157 170
 
158 171
     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
+
159 178
         self.possiblyRecordMovement(view)
160 179
 
161 180
     def on_activated(self, view):
  181
+        self._last_activated = view.id()
162 182
         self.possiblyRecordMovement(view)
163 183
 
164 184
     def possiblyRecordMovement(self, view):
@@ -211,6 +231,7 @@ def run(self, edit):
211 231
 
212 232
         location = history.back()
213 233
         if location:
  234
+            lock_buffer_scroll()
214 235
             print("back to: " + str(location.path) + ":" + str(location.line) + ":" + str(location.col))
215 236
 
216 237
             window = sublime.active_window()
@@ -221,7 +242,6 @@ def run(self, edit):
221 242
                 for view in window.views():
222 243
                     if view.id() == location.path:
223 244
                         found = True
224  
-                        lock_buffer_scroll()
225 245
                         window.focus_view(view)
226 246
                         pt = view.text_point(location.line, location.col)
227 247
                         view.sel().clear()
@@ -243,6 +263,7 @@ def run(self, edit):
243 263
 
244 264
         location = history.forward()
245 265
         if location:
  266
+            lock_buffer_scroll()
246 267
             print("forward to: " + str(location.path) + ":" + str(location.line) + ":" + str(location.col))
247 268
 
248 269
             window = sublime.active_window()
@@ -253,7 +274,6 @@ def run(self, edit):
253 274
                 for view in window.views():
254 275
                     if view.id() == location.path:
255 276
                         found = True
256  
-                        lock_buffer_scroll()
257 277
                         window.focus_view(view)
258 278
                         pt = view.text_point(location.line, location.col)
259 279
                         view.sel().clear()
2  Packages/User/Package Control.sublime-settings
... ...
@@ -1,5 +1,5 @@
1 1
 {
2  
-	"auto_upgrade_last_run": 1327962613,
  2
+	"auto_upgrade_last_run": 1328090570,
3 3
 	"installed_packages":
4 4
 	[
5 5
 		"BufferScroll",

0 notes on commit d6151cd

Please sign in to comment.
Something went wrong with that request. Please try again.