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

Resetting scroll/caret position after changing document #5

Closed
JorisVanEijden opened this issue Jul 6, 2024 · 5 comments
Closed

Resetting scroll/caret position after changing document #5

JorisVanEijden opened this issue Jul 6, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@JorisVanEijden
Copy link
Contributor

More of a "need help" or "question" than an issue with the code.

Situation:

  1. I have a large document loaded and showing.
  2. the view is scrolled pretty far down
  3. I replace the IBinaryDocument of the control with a much smaller one
  4. The view is now showing the last bytes of the new document

I want to scroll the view to the first byte of the document but seem to be unable to do so.

I have tried:

  • .HexView.ScrollOffset = new Vector(0.0, 0.0)
  • .Caret.GoToStartOfDocument()
    and put these
  • right after I change the document
  • in response to a DocumentChanged event

View: https://github.com/JorisVanEijden/Spice86/blob/feature/structure-viewer/src/Spice86/Views/StructureView.axaml
ViewModel: https://github.com/JorisVanEijden/Spice86/blob/feature/structure-viewer/src/Spice86/ViewModels/StructureViewModel.cs

Any help or advice would be welcome.

@Washi1337 Washi1337 added the bug Something isn't working label Jul 6, 2024
@Washi1337
Copy link
Owner

This can be considered a bug. Changing the document should change the scroll offset and rerender the hex view.

Fix should be in c9bbf84. If you could verify this fixes your issue that would be great.

@JorisVanEijden
Copy link
Contributor Author

That looks like it could fix something, but not my issue.

I'll try to explain how to reproduce it better:

  1. open AvaloniaHex demo application.
  2. by default it opens and load the AvaloniaHex.Demo.dll contents into the hexviewer
  3. scroll down a couple of pages
  4. go to File/Open and open a small file, for example AvaloniaHex.Demo.runtimeconfig.json
  5. see only the last line of the file in view

For step 5 I want to see the first line of the new file.

Expected:
image

Actual:
image

@Washi1337
Copy link
Owner

Washi1337 commented Jul 7, 2024

After commit c9bbf84 I cannot seem to reproduce this issue anymore in the demo app. Are you sure you pulled the latest code (note that this commit is not on nuget yet).

You can pull the nightly build from AppVeyor

@JorisVanEijden
Copy link
Contributor Author

I'm sorry. I was on my fork of AvaloniaHex and I had pulled the changes. I had my git view open that showed that commit as the latest one. Then I tested.
Unfortunately my git view was set to "main" and I happened to be in a detached Head state. So I was indeed missing the commit :(

Now the issue is solved. Many thanks for the quick fix and the awesome control.

@Washi1337
Copy link
Owner

Perfect, I will push a nuget update shortly then. Thanks for reporting the problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants