Skip to content

Commit

Permalink
tracking unsaved pages for all scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Klier committed Jul 29, 2010
1 parent 264af4e commit 72be8cb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions plugin/dokuvimki.vim
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ class DokuVimKi:

try:
self.xmlrpc.put_page(wp, text, sum, minor)
self.buffers[wp].page[:] = self.buffers[wp].buf
self.buffers[wp].page[:] = self.buffers[wp].buf
self.buffers[wp].need_save = False

if text:
vim.command('silent! buffer! ' + self.buffers[wp].num)
Expand Down Expand Up @@ -751,7 +752,9 @@ class DokuVimKi:
Checks whether the current buffer or a given buffer is modified or not.
"""

if "\n".join(self.buffers[buffer].page).strip() != "\n".join(self.buffers[buffer].buf).strip():
if self.buffers[buffer].need_save:
return True
elif "\n".join(self.buffers[buffer].page).strip() != "\n".join(self.buffers[buffer].buf).strip():
return True
else:
return False
Expand Down Expand Up @@ -967,6 +970,12 @@ class DokuVimKi:
self.buffer_setup()


def buffer_leave(self, wp):
if "\n".join(self.buffers[wp].buf).strip() != "\n".join(self.buffers[wp].page).strip():
self.buffers[wp].page[:] = self.buffers[wp].buf
self.buffers[wp].need_save = True


def buffer_setup(self):
"""
Setup edit environment.
Expand Down Expand Up @@ -1044,7 +1053,9 @@ class Buffer:

if type == 'acwrite':
self.diff = {}
self.need_save = False
vim.command('autocmd! BufEnter <buffer> py dokuvimki.buffer_enter("' + self.name + '")')
vim.command('autocmd! BufLeave <buffer> py dokuvimki.buffer_leave("' + self.name + '")')
vim.command("setlocal statusline=%{'[wp]\ " + self.name + "'}\ %r\ [%c,%l][%p]")

if type == 'nowrite':
Expand Down

0 comments on commit 72be8cb

Please sign in to comment.