Skip to content

Commit

Permalink
Merge 9dcbcf5 into 3dc461a
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Huynh committed Aug 26, 2019
2 parents 3dc461a + 9dcbcf5 commit 6c262f8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions plugin/black.vim
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,20 @@ def Black():
except Exception as exc:
print(exc)
else:
cursor = vim.current.window.cursor
current_buffer = vim.current.window.buffer
cursors = []
for i, tabpage in enumerate(vim.tabpages):
if tabpage.valid:
for j, window in enumerate(tabpage.windows):
if window.valid and window.buffer == current_buffer:
cursors.append((i, j, window.cursor))
vim.current.buffer[:] = new_buffer_str.split('\n')[:-1]
try:
vim.current.window.cursor = cursor
except vim.error:
vim.current.window.cursor = (len(vim.current.buffer), 0)
for i, j, cursor in cursors:
window = vim.tabpages[i].windows[j]
try:
window.cursor = cursor
except vim.error:
window.cursor = (len(window.buffer), 0)
print(f'Reformatted in {time.time() - start:.4f}s.')

def BlackUpgrade():
Expand Down

0 comments on commit 6c262f8

Please sign in to comment.