44full-function python IDE.
55'''
66from bdb import Breakpoint
7+ import sys
78import logging
89import pprint
910import collections
@@ -107,6 +108,10 @@ def __init__(self, nvim=None):
107108 self ._cond_dict = {} # type: Dict[str,List]
108109 self ._bp_config_dir = ""
109110 self ._bp_file = ""
111+ launcher_version_command = ' -c "import sys;print(sys.version_info[:2])"'
112+ self ._launcher_version = list (map (int , os .popen (
113+ self .launcher () +
114+ launcher_version_command ).read ().strip ()[1 :- 1 ].split (',' )))
110115 self .load_base_dir ()
111116 self .load_bp_file ()
112117 # update the __logger__ to use neovim for messages
@@ -168,6 +173,7 @@ def toggle_bp(self, buffname=None):
168173 if not buffname :
169174 buffname = self .cbname ()
170175 num_line = self .nvim .current .window .cursor [0 ]
176+ self .load_bp_file ()
171177
172178 if num_line not in self ._bps_placed [buffname ]:
173179 self ._bps_placed [buffname ].append (num_line )
@@ -194,29 +200,15 @@ def update_sign(self, buffname=None):
194200 self .signs_off (buffname )
195201 self .signs_on (buffname )
196202
197- # set sync so that the current buffer can't change until we are done
198- @neovim .autocmd ('BufRead' , pattern = '*.py' , sync = True )
199- def on_bufread (self ):
200- self .update_buffer ()
201-
202- # set sync so that the current buffer can't change until we are done
203- @neovim .autocmd ('BufNewFile' , pattern = '*.py' , sync = True )
204- def on_bufnewfile (self ):
205- self .update_buffer ()
203+ @neovim .autocmd ('TextChanged' , pattern = '*.py' , sync = True )
204+ def on_txt_changed (self ):
205+ buffname = self .cbname ()
206+ if buffname [:7 ] == 'term://' :
207+ return
208+ self .update_sign (buffname )
206209
207210 @neovim .autocmd ('BufEnter' , pattern = '*.py' , sync = True )
208211 def on_buf_enter (self ):
209- self .update_buffer ()
210-
211- @neovim .autocmd ('TextChanged' , pattern = '*.py' , sync = True )
212- def on_text_change (self ):
213- self .update_buffer ()
214-
215- @neovim .autocmd ('InsertLeave' , pattern = '*.py' , sync = True )
216- def on_insert_leave (self ):
217- self .update_buffer ()
218-
219- def update_buffer (self ):
220212 buffname = self .cbname ()
221213 if buffname [:7 ] == 'term://' :
222214 return
@@ -245,17 +237,15 @@ def load_bp_file(self):
245237 if len (num_line ) > 1 :
246238 self ._cond_dict ["{}:{}" .format (
247239 buffname , num_line [0 ])] = ", " .join (num_line [1 :])
240+ self .test_buffer (buffname )
241+ self ._bps_placed [buffname ].append (int (num_line [0 ]))
248242
249- if buffname in self ._bps_placed :
250- self ._bps_placed [buffname ].append (int (num_line [0 ]))
251- else :
252- self ._bps_placed [buffname ] = [int (num_line [0 ])]
243+ for buffname in self ._bps_placed :
253244 self ._bps_placed [buffname ] = list (set (self ._bps_placed [buffname ]))
254245 self ._bps_placed [buffname ].sort ()
255246
256247 buffname = self .cbname ()
257248 self .test_buffer (buffname )
258- self .signs_on (buffname )
259249
260250 def save_bp_file (self ):
261251 self .make_links ()
@@ -288,6 +278,10 @@ def make_links(self):
288278 f .write (tmp_input )
289279 os .remove (tmp_path )
290280 os .symlink (self ._bp_file , tmp_path )
281+ tmp_path = '{}saved-breakpoints-{}.{}' .format (
282+ self ._bp_config_dir , * self ._launcher_version )
283+ if not os .path .exists (tmp_path ):
284+ os .symlink (self ._bp_file , tmp_path )
291285
292286 def load_base_dir (self ):
293287 _home = os .environ .get ("HOME" , os .path .expanduser ("~" ))
@@ -308,7 +302,7 @@ def find_bp_files(self):
308302 for entry in os .listdir (self ._bp_config_dir ):
309303 if breakpoints_file_name in entry :
310304 files .append (entry )
311- return sorted (list ( set ( files ) ))
305+ return sorted (( files ))
312306
313307 def place_sign (self , buffname , num_line ):
314308 signcmd = "sign place {} line={} name={} file={}" .format (
0 commit comments