Skip to content

Commit

Permalink
Use unsaved file content when reparsing (#410)
Browse files Browse the repository at this point in the history
Fix #321
  • Loading branch information
niosus authored Jan 28, 2018
1 parent 9407f5e commit cf0166a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions plugin/clang/cindex50.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion plugin/completion/lib_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cf0166a

Please sign in to comment.