diff --git a/plugin/clang/cindex50.py b/plugin/clang/cindex50.py index a1641cf8..42e59d0e 100644 --- a/plugin/clang/cindex50.py +++ b/plugin/clang/cindex50.py @@ -2884,8 +2884,8 @@ def reparse(self, unsaved_files=None, options=0): print(value) if not isinstance(value, str): raise TypeError('Unexpected unsaved file contents.') - unsaved_files_array[i].name = name - unsaved_files_array[i].contents = value + unsaved_files_array[i].name = name.encode('utf-8') + unsaved_files_array[i].contents = value.encode('utf-8') unsaved_files_array[i].length = len(value) ptr = conf.lib.clang_reparseTranslationUnit(self, len(unsaved_files), unsaved_files_array, options) diff --git a/plugin/completion/lib_complete.py b/plugin/completion/lib_complete.py index 41c67bc1..997d0f2d 100644 --- a/plugin/completion/lib_complete.py +++ b/plugin/completion/lib_complete.py @@ -323,8 +323,14 @@ def update(self, view, settings): if not self.tu: log.error("translation unit is not available. Not reparsing.") return False + + # Prepare unsaved files. + file_name = view.file_name() + file_body = view.substr(sublime.Region(0, view.size())) + unsaved_files = [(file_name, file_body)] + start = time.time() - self.tu.reparse() + self.tu.reparse(unsaved_files=unsaved_files) end = time.time() log.debug("reparsed in %s seconds", end - start) # Store and potentially show errors to the user.