1. Ali Afshar
  2. pida-vim-nostate

Commits

Ali Afshar  committed ec50d22

Use buffer ids in vim editor

  • Participants
  • Parent commits 60cfa01
  • Branches default

Comments (0)

Files changed (3)

File pida/core/document.py

View file
     usage = 0
     last_opened = 0
 
+    editor_buffer_id = None
+
     @property
     def markup_string_if_project(self):
         if not self.project:

File pida/editors/vim/vim.py

View file
 
 
         if document is not self._current:
-            fn = document.filename
-            if document.unique_id in self._documents:
-                self._com.open_buffer(fn, **nothing_async)
+            if document.editor_buffer_id is not None:
+                self._com.open_buffer_id(document.editor_buffer_id,
+                                         **nothing_async)
             else:
-                self._com.open_file(fn, **nothing_async)
+
+                def tag_document(document=document):
+                    document.editor_buffer_id = self._com.get_buffer_number(
+                        document.filename)
+
+                self._com.open_file(document.filename,
+                                    reply_handler=tag_document,
+                                    error_handler=lambda *a: None)
                 self._documents[document.unique_id] = document
             self._current = document
 

File pida/resources/data/pida.vim

View file
     def get_buffer_number(self, path):
         return int(vim.eval("bufnr('%s')" % path))
 
-
     @method(DBUS_NS, in_signature='s')
     def open_buffer(self, path):
         vim.command('b!%s' % self.get_buffer_number(path))
 
+    @method(DBUS_NS, in_signature='i')
+    def open_buffer_id(self, bufnum):
+        vim.command('b!%s' % bufnum)
+
     # Saving
 
     @method(DBUS_NS)