-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: show contents of definition in preview window #4982
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
base: master
Are you sure you want to change the base?
fix: show contents of definition in preview window #4982
Conversation
Signed-off-by: hftsin <[email protected]>
Signed-off-by: hftsin <[email protected]>
Signed-off-by: hftsin <[email protected]>
Signed-off-by: hftsin <[email protected]>
Signed-off-by: hftsin <[email protected]>
Signed-off-by: hftsin <[email protected]>
|
Very interesting. I'll have to try this out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the preview window by including the content of definitions and references for non-TypeScript LSP responses. It updates test assertions to include a new key ("use_relative_paths"), introduces a helper function for safely reading a file’s specific line, and adjusts formatting functions in both definition and references modules to display the retrieved content.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_go_to_definition.vader | Updated test assertions to include "use_relative_paths" in the preview details |
| test/test_find_references.vader | Added an empty 'match' key to reference items for content consistency |
| autoload/ale/util.vim | Introduced SafeReadFileLine to read a particular line from a file safely |
| autoload/ale/references.vim | Modified formatting function to include file content in the reference preview |
| autoload/ale/definition.vim | Modified formatting function and command handler to incorporate file content and relative path options |
autoload/ale/util.vim
Outdated
| function! ale#util#SafeReadFileLine(filename, line) | ||
| let l:content = '' | ||
| if filereadable(a:filename) | ||
| let l:content = readfile(a:filename, '', a:line)[-1] |
Copilot
AI
Jun 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If performance becomes an issue for large files, consider using a method that reads only the target line rather than reading all lines up to it.
| let l:content = readfile(a:filename, '', a:line)[-1] | |
| let l:content = getline(a:line, a:filename) |
Co-authored-by: Copilot <[email protected]>
|
I assume this PR may be closed as the same functionality was merged with #5001? |
…in-preview-window Signed-off-by: hftsin <[email protected]>
Signed-off-by: hftsin <[email protected]>
…ow' into fix/show-content-in-preview-window
Signed-off-by: hftsin <[email protected]>
|
I revise this PR to show definitions / implementations in preview window. E.g., show all implementations for go interface, @w0rp pls help review 🙏 |
For non-ts LSP response, it only shows the filename, line number and column number. This PR enhance the preview window by showing the contents of definitions and references.