Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use buffer-chars-modified-tick to reparse less #53

Merged
merged 1 commit into from
Oct 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions rjsx-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -775,14 +775,16 @@ closing tag was parsed."
(throw 'rjsx-eof-while-parsing t))
(t (js2-add-to-string c)))))))

(js2-deflocal rjsx-buffer-chars-modified-tick 0 "Variable holding the last per-buffer value of `buffer-chars-modified-tick'.")

(defun rjsx-maybe-reparse ()
"Called before accessing the parse tree.
For small buffers, will do an immediate reparse to ensure the
parse tree is up to date."
;; TODO: We could look at the last parse time and the last buffer
;; modification time to avoid some reparsing
(when (<= (point-max) rjsx-max-size-for-frequent-reparse)
(js2-reparse)))
(when (and (<= (point-max) rjsx-max-size-for-frequent-reparse)
(/= rjsx-buffer-chars-modified-tick (buffer-chars-modified-tick)))
(js2-reparse)
(setq rjsx-buffer-chars-modified-tick (buffer-chars-modified-tick))))

(defun rjsx--tag-at-point ()
"Return the JSX tag at point, if any, or nil."
Expand Down