Washi1337 / AvaloniaHex

A hex editor control for Avalonia.
MIT License
78 stars 7 forks source link

Resetting scroll/caret position after changing document #5

Closed JorisVanEijden closed 4 months ago

JorisVanEijden commented 4 months ago

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:

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 commented 4 months ago

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

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

JorisVanEijden commented 4 months ago

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 commented 4 months ago

After commit c9bbf84336099732835c4185df4a3ea00715f860 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 commented 4 months ago

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 commented 4 months ago

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