Giter Site home page Giter Site logo

Comments (12)

xuehy avatar xuehy commented on August 11, 2024 1

@MarcoHassan the function lsp-f-canonical is in lsp-mode.el

from lsp-treemacs.

thomashilke avatar thomashilke commented on August 11, 2024 1

@xuehy yes
@MarcoHassan Well, I did fix lsp-f-canonical naively inplace and reevaluate the defun. This modification actually breaks other important stuff.

I see 2 ways to approach the problem:

  1. Fix lsp-f-ancestor-of? since it is what fails here, or
  2. understand why the diagnostics hashtable returned by lsp-diagnostics hasn't the correct casing in the first place.

As long as you stay on Windows, a quick and dirty way to do it is to replace lsp-f-ancestor-of? with:

(defun lsp-f-ancestor-of? (path-a path-b)
  "Return t if PATH-A is an ancestor of PATH-B.
Symlinks are not followed."
  (unless (lsp-f-same? path-a path-b)
    (s-prefix? (concat (lsp-f-canonical (downcase path-a)) (f-path-separator))
               (lsp-f-canonical (downcase path-b)))))

Just edit-it in place in your .emacs.d/elpa folder and restart emacs. It will probably be overwritten a the next package update.

from lsp-treemacs.

deb75 avatar deb75 commented on August 11, 2024

Hello,

No clue ?

I will test on linux, I wonder why it would work on linux and not on windows. How could it be platform dependent ?

A question of line ending (lf, crlf) ?

from lsp-treemacs.

ulises avatar ulises commented on August 11, 2024

Same thing happens in mac os. Additionally, when trying to unfold an error tree I get:

let: Wrong type argument: char-or-string-p, nil

from lsp-treemacs.

asmodeus812 avatar asmodeus812 commented on August 11, 2024

I am also facing the same issue, the nodes do not expand/unfold, @yyoncho any idea ?

from lsp-treemacs.

yyoncho avatar yyoncho commented on August 11, 2024

@asmodeus812 open separate issue, we have to debug it. As a side note, I favour helm-lsp-diagnostics over lsp-treemacs tree view.

from lsp-treemacs.

xuehy avatar xuehy commented on August 11, 2024

Still not solved? I am facing the same issue.

from lsp-treemacs.

cmburn avatar cmburn commented on August 11, 2024

@yyoncho I think @deb75 and @asmodeus812 are referring to the same issue in that the nodes simply don't expand, which I've got as well. helm-lsp-diagnostics displays the errors correctly, so I'm guessing it's not an LSP issue

from lsp-treemacs.

thomashilke avatar thomashilke commented on August 11, 2024

I am affected with the same issue under Windows 10, Emacs 29.0.50.

It turns out that the issue is in the function lsp-treemacs-errors--list-files at line 1189. The function lsp-f-ancestor-of? gets the folder of the workspace, and the path of a file that have diagnostics associated. On my machine, the case of the folder is different than the case of the file. For example, when debugging, I get in the *Message* buffer:

Result: "c:/[Redacted]/AcmeCorp.PlanarMachining"

Result: "c:/[redacted]/acmecorp.planarmachining/visualizers/curve2d/curve2dvisualizer.test/obj/debug/net48/curve2dvisualizer.test.assemblyinfo.cs"

So, even if the folder contains the file according to the NTFS/whatever filesystem, lsp-f-ancestor-of? returns nil if the casing doesn't match exactly.

If you patch the function lsp-f-canonical to downcase the filename like so:

(defun lsp-f-canonical (file-name)
  "Return the canonical FILE-NAME, without a trailing slash."
  (directory-file-name (expand-file-name (downcase file-name))))

Then the Error List buffer shows the files with the diagnostics correctly: the tree can be expanded, and diagnostics double-clicked to navigate to the faulty code.

The above fix is probably not the right thing to do, but I couldn't find the proper way to do it. Honestly, comparing paths should be something that is delegated to some OS api, and everything that is done in Elisp is an approximation of that, at least on Windows...

Anyway, I hope that my little analysis helps with fixing the issue for the Windows users!

from lsp-treemacs.

MarcoHassan avatar MarcoHassan commented on August 11, 2024

Hi I am interested in the fix. Can you develop on it - in specific on the patch.

There is no function lsp-f-canonical in here.

Are you suggesting replacing lsp-f-ancestor.of? with it or what?

Thank you in advance.

from lsp-treemacs.

xuehy avatar xuehy commented on August 11, 2024

@thomashilke yes we must make sure the code only runs on windows. Since I use emacs on both win and Linux, here's my quick dirty fix which can be used in both OS:

(defun lsp-f-ancestor-of? (path-a-raw path-b-raw)
  "Return t if PATH-A is an ancestor of PATH-B.
Symlinks are not followed."
  (let ((path-a (if (eq system-type 'windows-nt) (downcase path-a-raw) (path-a-raw)))
	(path-b (if (eq system-type 'windows-nt) (downcase path-b-raw) (path-b-raw))))
    
	(unless (lsp-f-same? path-a path-b)
	  (s-prefix? (concat (lsp-f-canonical path-a) (f-path-separator))
		     (lsp-f-canonical path-b)))))

It seems that only fixing lsp-f-ancestor-of? is still not enough with the error message
lsp--on-idle wrong type argument stringp nil. Tracing the error, I found its root is function lsp-f-same?. Finally, my patch is:

(defun lsp-f-ancestor-of-patch (path-args)
  (mapcar (lambda (path) (downcase path)) path-args))

(when (eq system-type 'windows-nt) 
  (advice-add 'lsp-f-ancestor-of? :filter-args #'lsp-f-ancestor-of-patch)
  (advice-add 'lsp-f-same? :filter-args #'lsp-f-ancestor-of-patch))

which can be placed in your own init files and will not be overwritten when lsp packages get updated.

from lsp-treemacs.

yyoncho avatar yyoncho commented on August 11, 2024

The above fix is probably not the right thing to do, but I couldn't find the proper way to do it. Honestly, comparing paths should be something that is delegated to some OS api,

There are OS calls(file-truename) but we avoid them on purpose because they are pretty much killing lsp-mode performance. Thus all these ugly hacks.

I will accept this patch as a PR.

from lsp-treemacs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.