-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Information bar isn't navigating to the right code block #986
Comments
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request. |
should this be fixed? if yes, then I can work on it. assign this to me. |
Hi @Saumya40-codes please go ahead |
Hi @satishkumarsajjan @Saumya40-codes already suggested himself in the description, you can probably help to review his work. |
Oh cool then. @Saumya40-codes let me know if I can be of any help. |
Hey, @Amzani @fmvilas
under the function
in the file src\services\parser.service.ts is giving wrong range of starting and ending line for the given file path/jsonPath I'm finding it hard to understand how function getRangeForJsonPath here gives the range of starting and ending part of the line. I will be still looking to find the problem here but can you explain how it works internally but? maybe here or slack anywhere it is possible. for instance when clicked to Schemas the following range appears @satishkumarsajjan can you help here? |
I am going through it now. |
@Saumya40-codes I found out what actually is happening. This is what we see in the apps editor:(first image) And this is what the function is getting the positions from:(second image) so now when i click on "Messages" in nav, I get these as start and end line numbers:(third image) which is actually correct according to second image. Which is again correct according to second image. |
In short, we are using json logic to yaml file. |
My proposed solution: async scrollTo(jsonPointer: string | Array<string | number>, hash: string) {
try {
const range = this.svcs.parserSvc.getRangeForJsonPath(
'asyncapi',
jsonPointer
);
if (range) {
await this.scrollToEditorLine(range.start.line + 1);
}
await this.scrollToHash(hash);
this.emitHashChangeEvent(hash);
} catch (e) {
console.error(e);
}
} this function which is This is what I could come up with. If you have better approach, let's discuss. |
@Vishal2002 @satishkumarsajjan thanks! |
@Amzani Can I also work on this issue? |
We will need to iterate through each line of the code anyways isn't it (for .yaml files)? I think it will be complex implementation without knowing how maintainers want it to work like, or how existing (json) part works internally 😅 |
@Vishal2020 sure you can coordinate with @Saumya40-codes and create a PR. |
@Saumya40-codes It would be great if we could work together on this issue. I think we need to write a separate function which will find the jsonpointer in the |
Ok then. But I've already tried to solve this using that way, but it doesn't work in all cases. |
Hey, @Amzani, @princerajpoot20 I've resolved the bug and following is the final output: AsyncAPI.Studio.-.Brave.2024-03-08.18-19-57.mp4(Have tried testing this on all examples and it works just fine) The problem as suggest by @Vishal2002 and @satishkumarsajjan (thanks to them !) was that the existing scrollTo function for scrolling to the desirable line was only working when the file type was JSON Now as a fix in services/navigation.service.ts file I have made following changes to scrollTo function
Basically, i'm just checking the file type, if it is json im keeping it as it is but if it is yaml i've built another method to get the desirable range. Here is that code(have left the comments)
Might have overdone the things but I tried to keep it as optimized as possible. |
@Saumya40-codes It looks nice 👍👍 |
If it works then raise a PR. Members will review it. The app already uses stoplight lib to parse and get the path. It also does it for yaml, you could have used it and that would have been easy. But if this works then i see no issue. Nice work. |
Oh I wasn't fully aware about that!! |
Describe the bug
There are sections in information bar in studio which are made to navigate to particular part of the code block and view more information about that, but currently on clicking many of them, it only navigates to the end of the code block.
How to Reproduce
Steps to reproduce the issue. Attach all resources that can help us understand the issue:
AsyncAPI.Studio.-.Google.Chrome.2024-03-05.17-46-13.mp4
Expected behavior
Expected behaviour will be the navigation on the right part of the code block. For instance on clicking schema, the following part should appear
If it is ok, than I will like to work on this bug to solve it.
Thanks!!
The text was updated successfully, but these errors were encountered: