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

Fixup file name and line numbers when evalulating a form #329

Open
marcomorain opened this issue Sep 20, 2019 · 7 comments
Open

Fixup file name and line numbers when evalulating a form #329

marcomorain opened this issue Sep 20, 2019 · 7 comments
Assignees
Labels

Comments

@marcomorain
Copy link

@marcomorain marcomorain commented Sep 20, 2019

When I eval a chunk of code using the "Calva: evaluate current top level form..." commands, the file name is auto-generated as form-init2144587467489926643.clj, and the line numbers start from 1 for the chunk that I have evaluated.

This leads to confusing data in a stack trace. Let's say I eval a chunk of code in a file named storage_test.clj, and run a test that fails. The output is as follows:

FAIL in (storage-stores-stuff) (form-init2144587467489926643.clj:12)

If instead, I evaluate the entire file, and then run the test, the output changes to:

FAIL in (storage-stores-stuff) (/Users/foo/bar/baz/storage_test.clj:43)

I can click on the string /Users/foo/bar/baz/storage_test.clj:43 in VS Code and be taken directly to that line of code. I cannot click on form-init2144587467489926643.clj:12, which slows me down, and makes it harder to debug problems.

Suggestion:

When Calva evaluates a form, it should specify the filename, column and initial line number when calling nrepl:

https://github.com/nrepl/nrepl/blob/cdd688f22e65580e9b52d9a8def9ad42a530914a/src/clojure/nrepl/middleware/interruptible_eval.clj#L157-L159

This will make everything line up much better.

PEZ added a commit that referenced this issue Sep 20, 2019
Fixes #329
@PEZ

This comment has been minimized.

Copy link
Collaborator

@PEZ PEZ commented Sep 20, 2019

Thanks. Looking at this a bit. I am not sure I can fix the actual case you mention with re-rerunning tests (haven't even looked at that yet, so it could be it is entirely fixable), but for regular evaluations it certainly works providing that info.

Will look at it a bit more and see what I can do.

@PEZ PEZ self-assigned this Sep 20, 2019
@PEZ

This comment has been minimized.

Copy link
Collaborator

@PEZ PEZ commented Sep 21, 2019

How do you run those tests, @marcomorain ? My output does not match what you show there...

@PEZ

This comment has been minimized.

Copy link
Collaborator

@PEZ PEZ commented Sep 21, 2019

Can you test this VSIX package out, @marcomorain ? And let me know if it makes the difference you wanted, or not.

@marcomorain

This comment has been minimized.

Copy link
Author

@marcomorain marcomorain commented Sep 24, 2019

How do I try the package out @PEZ ? I don't see a file anywhere?

@marcomorain

This comment has been minimized.

Copy link
Author

@marcomorain marcomorain commented Sep 24, 2019

OK, I found the file in the Releases section of GH. Thanks for working on this.

The line numbers are now fixed, but not the file name.

To run tests, I eval the following in the REPL:

(clojure.test/test-var #'name-of-the-test)
@PEZ

This comment has been minimized.

Copy link
Collaborator

@PEZ PEZ commented Sep 24, 2019

Sorry, missed attaching the vsix. 😄

@PEZ

This comment has been minimized.

Copy link
Collaborator

@PEZ PEZ commented Sep 26, 2019

@marcomorain , if you want to dig in to this some, please do. Or, if not, let me know and I'll have another go at it.

@bpringe bpringe added the enhancement label Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.