Don't crash the Vim plugin

Fixes #312
This commit is contained in:
Łukasz Langa 2018-06-07 11:40:41 -07:00
parent ef362b4ea8
commit 75a9447448

View File

@ -97,8 +97,9 @@ def Black():
start = time.time()
fast = bool(int(vim.eval("g:black_fast")))
line_length = int(vim.eval("g:black_linelength"))
mode = black.FileMode.AUTO_DETECT
if bool(int(vim.eval("g:black_skip_string_normalization"))):
mode = black.FileMode.AUTO_DETECT & black.FileMode.NO_STRING_NORMALIZATION
mode |= black.FileMode.NO_STRING_NORMALIZATION
buffer_str = '\n'.join(vim.current.buffer) + '\n'
try:
new_buffer_str = black.format_file_contents(buffer_str, line_length=line_length, fast=fast, mode=mode)