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

xref-js2 false-positive checks keeps all checked buffer files open #15

Open
mohkale opened this issue Sep 9, 2019 · 3 comments
Open

Comments

@mohkale
Copy link
Contributor

mohkale commented Sep 9, 2019

this is the code block in question.

(defun xref-js2--false-positive (candidate)
  "Return non-nil if CANDIDATE is a false positive.
Filtering is done using the AST from js2-mode."
  (let* ((file (map-elt candidate 'file))
         (buffer-open (get-file-buffer file)))
    (prog1
        (with-current-buffer (find-file-noselect file t)
          (save-excursion
            (save-restriction
              (widen)
              (unless (or (eq major-mode 'js2-mode)
                          (seq-contains (map-keys minor-mode-alist) 'js2-minor-mode))
                (js2-minor-mode 1))
              (goto-char (point-min))
              (forward-line (1- (map-elt candidate 'line)))
              (search-forward (map-elt candidate 'symbol) nil t)
              ;; js2-mode fails to parse the AST for some minified files
              (ignore-errors
                (let ((node (js2-node-at-point)))
                  (or (js2-string-node-p node)
                      (js2-comment-node-p node))))))))))

there's a get-file-buffer call in the let clause, but the evaluated variable is never used. the body is also wrapped in a prog1 despite not needing to be. Both these reasons lead me to conclude the that after the false-positive-check buffer-open was supposed to be used to check whether the opened buffer should be killed or not (killed if the corresponding file wasn't already open). For one reason or another it was either never implemented or deprecated in favor of the current solution. Regardless, for large projects (and over controlling weirdos like myself 😈) having so many open buffers is inconvenient.

@mohkale
Copy link
Contributor Author

mohkale commented Sep 10, 2019

Okay. I tried finding a way to close it, but noticed a steep drop off in response speed. using profiler, it seems that my projectile hook is slowing down the file opening time for every file, which for large projects makes it feel like it's taking ages (takes upto 5 minutes the first time). After being opened once it's noticably faster tho. I guess, closing the open buffers impairs the usability of this plugin. What a shame, I guess I'll have to only use xref-js2 in essential situations or maybe find a way to disable any hooks for js2 mode when used with this plugin.

@NicolasPetton
Copy link
Collaborator

NicolasPetton commented Sep 14, 2019 via email

@mohkale
Copy link
Contributor Author

mohkale commented Sep 15, 2019

That seems reasonable obvious, why didn't I think of that? 😭😭😭 I'm working on some other stuff at the moment, but when I get a chance I'll try to implement and see how it works. Thnx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants