Commits

Ali Afshar committed 263b086

Fixed closing documents

  • Participants
  • Parent commits ec50d22

Comments (0)

Files changed (2)

pida/editors/vim/vim.py

     def vim_BufDelete(self, file_name):
         if file_name == '':
             return
-        self.svc.remove_file(file_name)
+        #self.svc.remove_file(file_name)
         self.svc.boss.get_service('buffer').cmd('close_file', file_name=file_name)
 
     def vim_VimLeave(self):
 
     def open(self, document):
         """Open a document"""
-
-
         if document is not self._current:
             if document.editor_buffer_id is not None:
                 self._com.open_buffer_id(document.editor_buffer_id,
         pass
 
     def close(self, document):
-        if document.unique_id in self._documents:
-            self._remove_document(document)
-            self._com.close_buffer(document.filename, **nothing_async)
+        if document.editor_buffer_id is not None:
+            self._com.close_buffer_id(document.editor_buffer_id,
+                                      **nothing_async)
         return True
 
     def remove_file(self, file_name):
         if document is not None:
             self._remove_document(document)
 
-    def _remove_document(self, document):
-        del self._documents[document.unique_id]
 
     def _get_document_for_filename(self, file_name):
         for uid, doc in self._documents.iteritems():

pida/resources/data/pida.vim

         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)
+    def open_buffer_id(self, bufid):
+        vim.command('b!%s' % bufid)
 
     # Saving
 
     def close_buffer(self, path):
         vim.command('confirm bd%s' % self.get_buffer_number(path))
 
+    @method(DBUS_NS, in_signature='i')
+    def close_buffer_id(self, bufid):
+        if int(vim.eval("bufexists('%s')")):
+            vim.command('confirm bd%s' % bufid)
+
     @method(DBUS_NS)
     def close_current_buffer(self):
         vim.command('confirm bd')
         pass
 
     @signal(DBUS_NS, signature='s')
-    def BufDelete(self, filename):
-        print 'BufDelete'
+    def BufDelete(self, file_name):
+        pass
 
     @signal(DBUS_NS)
     def VimEnter(self):