How to loop through all the buffers of a window?
I want to process all the views and add all the words to the auto completion. Simultaneously, I am check for each word I got, if the total time has not been passed the limit of 0.3 seconds.
Currently I can think of creating a set and adding to it, each view buffer id, so I do not process the same buffer again, if its buffer id is already on the set, when I am looping through the views after doing sublime.active_window().views()
.
buffers_id_set = set()
start_time = time.time()
# The current buffer is already processed
buffers_id_set.add( active_view.buffer_id() )
for view in views:
view_buffer_id = view.buffer_id()
if view_buffer_id not in buffers_id_set:
buffers_id_set.add( view_buffer_id )
if time.time() - start_time > 0.3:
break