From 8e34a59045fa4385feebd7a2eec88a8005cb3af8 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 13 Apr 2017 22:47:31 +0200 Subject: [PATCH] initialize.py: handle reloading of the plugin (#659) Do not keep adding jedi_vim_path to sys.path. --- initialize.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/initialize.py b/initialize.py index 3f49ae8..0636889 100644 --- a/initialize.py +++ b/initialize.py @@ -9,8 +9,10 @@ try: import os, sys, vim jedi_path = os.path.join(vim.eval('expand(s:script_path)'), 'jedi') sys.path.insert(0, jedi_path) + jedi_vim_path = vim.eval('expand(s:script_path)') - sys.path.insert(0, jedi_vim_path) + if jedi_vim_path not in sys.path: # Might happen when reloading. + sys.path.insert(0, jedi_vim_path) except Exception as excinfo: raise Exception('Failed to add to sys.path: {0}\n{1}'.format( excinfo, traceback.format_exc())) @@ -21,4 +23,4 @@ except Exception as excinfo: raise Exception('Failed to import jedi_vim: {0}\n{1}'.format( excinfo, traceback.format_exc())) finally: - sys.path.pop(1) + sys.path.remove(jedi_path)