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

Finish read-only parity of hex editor #314

Merged
merged 9 commits into from
Nov 29, 2021
Merged

Finish read-only parity of hex editor #314

merged 9 commits into from
Nov 29, 2021

Conversation

connor4312
Copy link
Member

This finishes the read-only side of the hex editor. Supports keyboard selection, the data inspector, multiple ranges, all that...

image

Recapping from what I discussed in standup, the basic model is that there's a scroll container that is sized and just uses native scrolling. Inside that is the sticky-positioned data view (sticky, since setting it to fixed prevents scrolling from propagating). This is a static display of data. Only rows in the view are rendered, and as scroll happens the rows are moved, added, and removed.

I mentioned that I was having some performance issues with Recoil here. I've got this so that it's now okay. It's now 'okay'. Selection updates take about 5ms on my macbook, and scrolling takes about 8ms. It's not great but acceptable. If it ends up being problematic we can look at optimizing it; current usage is relatively idiomatic React however.

Note that when testing or evaluating performance, you want to run npm run watch -- --minify to create a production build. The performance characteristics of React when built for production are significantly better than in development.

@connor4312 connor4312 requested a review from lramos15 November 9, 2021 23:57
@connor4312 connor4312 self-assigned this Nov 9, 2021
@lramos15
Copy link
Member

recording
Running npm install && npm run watch -- --minify leads to a broken experience. The data inspector doesn't load, the rows seem unevenly spaced, and there is some ghosting when moving the focus. Did I miss a step?

@connor4312
Copy link
Member Author

Forgot to push my last commit, fixed 😬

Copy link
Member

@lramos15 lramos15 left a comment

Choose a reason for hiding this comment

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

I would love to see more comments / explanation around all the special math. I also wasn't great about that and feel like that's the main barrier to the hex editors maintainability. There's a lot of thinking that needs to be done to adjust for all the virtualization and sizing. Why are some things floored vs ceiled? Why are some things -1? Things like this will be forgotten in a couple months

it("round trips", async () => {
const backup = new Backup(await getTempFile());
await backup.write(edits);
expect(await backup.read()).to.deep.equal(edits);
Copy link
Member

Choose a reason for hiding this comment

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

Is there a benefit to chai over mocha's built in assert.strictDeepEqual?

Copy link
Member Author

Choose a reason for hiding this comment

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

For strictDeepEqual, not so much, but Chai has additional assertions which makes writing tests easier and/or produces higher quality assertion messages, as well as a plugin API. I don't feel super strongly about it though so I'm fine using just assert if you'd prefer.

Copy link
Member

Choose a reason for hiding this comment

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

If you think chai will be beneficial in the future let's keep it. However, do you think we should be using Jest and React's testing library https://testing-library.com/docs/react-testing-library/intro/ so we can test component rendering and those sorts of things?

@connor4312
Copy link
Member Author

Some math has since changed and moved, so I added comments in bcfec6a to the relevant sections.

* wip

* fixup, get replacement editing working

* unsaved ranges and go to offset

* chore: remove dead code

* feat: implement virtual scroll

* wip

* refactor: add comments and clean up math

* find/replace

* feat: undo/redo

* fix: focus issues with go to offset quickpick

* fix: focus back to the byte when hiding find widget

* fix: binary in search, cap results by default for perf, progress

* fix: don't change selected toolbar background on hover

* fix: issues with length changes and large find/replace

* feat: add replace toggle

* feat: show better validation for find widget errors

* feat: wip on string search with placeholders

This approach will not work, it's wildcards and not placeholders. But committing it if we need it in the future...

* feat: support placeholders in search

* feat: persist webview state information

* fix: make revert work
Copy link
Member

@lramos15 lramos15 left a comment

Choose a reason for hiding this comment

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

👍

@lramos15 lramos15 merged commit 87c036f into streaming-1 Nov 29, 2021
@lramos15 lramos15 deleted the streaming-2 branch November 29, 2021 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants