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

fix: Return whole lines when looking up source code #2193

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

dividedmind
Copy link
Collaborator

This pull request includes several changes to improve the handling and testing of source code snippets in the buildContext and lookupSourceCode functions. The most important changes include modifying the lookupSourceCode function to return an object with content and location, updating the buildContext function to accommodate this change, and adding new unit tests for lookupSourceCode.

Improvements to lookupSourceCode function:

  • packages/cli/src/rpc/explain/lookupSourceCode.ts: Modified lookupSourceCode to return an object with content and location instead of an array of strings. This change ensures that the returned snippet includes both the content and its precise location. [1] [2] [3]
  • Make sure to read and return whole lines when looking up the source code. The location returned corresponds to real file location and the computed line extent.

Updates to buildContext function:

Unit tests:

@dividedmind dividedmind self-assigned this Jan 9, 2025
Copy link
Contributor

@kgilpin kgilpin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a good change. My only comment is that since the PR description states that it's ensuring that complete lines are returned, it would be great to see a test case in which the line would have been split in the previous implementation, but is now handled correctly.

@dividedmind
Copy link
Collaborator Author

It looks like a good change. My only comment is that since the PR description states that it's ensuring that complete lines are returned, it would be great to see a test case in which the line would have been split in the previous implementation, but is now handled correctly.

Good point! It must have slipped my mind because there were no tests for the previous implementation.

@dividedmind dividedmind force-pushed the fix/whole-snippets-from-appmaps branch from 3182837 to 35e9042 Compare January 13, 2025 13:52
@dividedmind dividedmind merged commit 1061f19 into main Jan 13, 2025
23 checks passed
@appland-release
Copy link
Contributor

🎉 This PR is included in version @appland/appmap-v3.181.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dividedmind dividedmind deleted the fix/whole-snippets-from-appmaps branch January 21, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants