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

Implemented Indexable ByteValue Indications #883

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

stricklandrbls
Copy link
Collaborator

@stricklandrbls stricklandrbls commented Oct 20, 2023

  • Added indexable indication array for ByteValues within the viewport displays.
  • Created categorical byte indiciations values & CSS selectors.
Screenshot: ByteValue Search Result Indication

image

Screenshot: ByteValue Replace Result Indication

image
Replacing 0x 00 00 00 -> 0x FF 01 FF

Closes #784

@stricklandrbls stricklandrbls added enhancement New feature or request typescript data editor Issues related to the Data Editor capability labels Oct 20, 2023
@stricklandrbls stricklandrbls added this to the 1.4.0 milestone Oct 20, 2023
@stricklandrbls stricklandrbls self-assigned this Oct 20, 2023
@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch from 5c609fa to 686c745 Compare October 20, 2023 19:28
@stricklandrbls
Copy link
Collaborator Author

stricklandrbls commented Oct 23, 2023

Issue Resolved

There seems to be some unintended merge changes between this branch and main that I did not change myself. These following items are marked as being removed:

  • src/language/dfdl.ts
  • src/providers/attributeHover.ts
  • src/providers/attributeHoverItems.ts

I'm currently working on resolving this.

@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch 3 times, most recently from 2fba695 to 08439de Compare October 23, 2023 16:23
Copy link
Collaborator

@NolanMatt NolanMatt left a comment

Choose a reason for hiding this comment

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

Looks good

@stricklandrbls
Copy link
Collaborator Author

I've come across a bug in the on:click event propogation while re-basing another ticket to include this PR's changes.

I'm currently working on a fix for this.

@scholarsmate
Copy link
Contributor

I hope to get to this review tomorrow.

@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch from 08439de to 367275a Compare November 1, 2023 01:44
@stricklandrbls
Copy link
Collaborator Author

The issue I ran into was due to the fact that I moved the listener events for the highlight selection. Previously, there were listeners for each ByteValue but it was less load on the extension to have a single listener at the ByteValue container level, then parse which element fired the event.

There are two separate on:mousedown and on:mouseup events that are distinct but the child components during a single byte selection only have on:click events. This meant that the parent container was still registering the mousedown and preventing a full click/release cycle needed for a click.

@scholarsmate
Copy link
Contributor

scholarsmate commented Nov 1, 2023

This is a nice new feature. We can see replaced sequences.

Screenshot 2023-10-31 at 22 32 14

We can select a range of bytes to edit.

Screenshot 2023-10-31 at 22 34 15

We can select a single byte to edit in-line.

Screenshot 2023-10-31 at 22 34 41

One minor inconsistency is that we we can close the multi-byte selection using the X in the 3rd column, but we lack that for the single byte selection. To "escape out of" single byte mode edit, ESC works, but doesn't "escape out of" multi-byte edit mode. It would be good to have ESC and the X work for both selection modes.

Things get more complicated when changes are made, then undone. The highlights are now incorrect when changes have been undone. It would be good to have the highlights work with undo/redo.

Screenshot 2023-10-31 at 22 48 32

@stricklandrbls
Copy link
Collaborator Author

stricklandrbls commented Nov 1, 2023

Things get more complicated when changes are made, then undone. The highlights are now incorrect when changes have been undone. It would be good to have the highlights work with undo/redo.

The issue with the undo / redo seems to be within the fact that there's no longer a history of changes being kept with messages between the extension, server, and UI. I believe this was changed with the search & replace got restructured to be incremental search & replace. Those messages being sent don't contain any data.

I think ideally, when redo/undo changes are made, there should be some data in the server-extension-UI pipeline to have the UI accurately display the viewport. Similar to how the scrollViewport, viewportRefresh, and requestEditedData are done.

That being said, something should be done to rectify this highlighting issue but will have to be in sync with what changes are going to be made to search / replace in the future.

@scholarsmate
Copy link
Contributor

@stricklandrbls, that's right. If a 1M file of 'a's gets changed to 'xX' that's a lot to keep track of and will not scale well. I'd recommend doing the same here. Just highlight the last replacement and the current search. There will be no highlighting for replace all or replace rest since that's all done on the server side and is opaque on the client side.

If I insert or delete bytes the highlights float on top and do not float with the content. If I delete or insert bytes in the middle of a selection, it doesn't shrink or grow. If I revert all changes, the highlights remain.

Maybe the "fix" is to clear the selections when any edit is made or any change is undone/redone. I think it's still possible to show the last replacement and the current search, but any other change to the content clears the selections.

@stricklandrbls
Copy link
Collaborator Author

... If I delete or insert bytes in the middle of a selection, it doesn't shrink or grow. If I revert all changes, the highlights remain.

Can you elaborate on this one? I was able to make a selection and have the highlights grow & shrink according to the length of the edited segment.
shrink-grow-highlights

@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch from 367275a to d9cd8a8 Compare November 1, 2023 16:49
@scholarsmate
Copy link
Contributor

scholarsmate commented Nov 1, 2023

@stricklandrbls, I was deleting and inserting into the highlights from a search and replace. The selection you're showing is concerning unless "overwrite only" is the selected editing mode. It just grows the length of the replacement string. If I'm not in "overwrite only" mode and I select 3 bytes and I replace that with 10 bytes, I need those 3 bytes replaced with the new bytes (growing the file by 7 bytes), not just overwrite 10 bytes with 10 new bytes.

@stricklandrbls
Copy link
Collaborator Author

stricklandrbls commented Nov 1, 2023

I need those 3 bytes replaced with the new bytes (growing the file by 7 bytes), not just overwrite 10 bytes with 10 new bytes.

Is that not fundamentally how the applyChanges event works? Even on the extension side the message data members are:

  • originalDataSegment - The selected data from the unedited viewport perspective.
  • editedSegment - The segment of data to replace the original.
  • offset - Where in the viewport to apply the overwrite.

The highlights are based off the byte length of the selectionDataStore
replace-grow
Here I append abc to PDF and the replacement results is PDFabc-1... growing the file by 3 bytes.

It might help if I have different indications for the raw, user-selected, selection and what is being appended / removed from that selection. Like something in the below gif:
new-highlight

@scholarsmate
Copy link
Contributor

scholarsmate commented Nov 1, 2023

@stricklandrbls, these selections should not grow unless we're doing overwrite only. If we are doing overwrite only, I like the second GIF that shows what additional bytes will be overwritten if the changes are applied.

applyChanges by default effectively deletes the original segment, and inserts the new one. If overwrite only is used, it effectively overwrites the bytes starting at the given offset for the length of the edited segment. I say effectively because Ωedit™ has an algorithm to change one segment into another using the smallest change possible.

You could use Ωedit™ viewports to power the selections and keep them updated when changes are made. They are designed to track changes in data segments from a content perspective (use isFloating = true) or from a position perspective (use isFloating = false). In this case, we want the the viewport to move with changes in the content, so use isFloating = true. Ωedit™ can efficiently handle many of these for you and is one of the reasons for having floating viewports.

Here is an example in a TypeScript test of using a viewport to track some content in a session. It doesn't include what happens to the 'LABEL' if the label itself gets changed, but we can make it behave any way we want by subscribing to its viewport events.

@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch from d9cd8a8 to c6eebf3 Compare November 3, 2023 01:36
@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch from c6eebf3 to ae84965 Compare November 20, 2023 21:47
@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch 5 times, most recently from 4f5eee8 to 58efdc7 Compare November 28, 2023 17:43
@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch 5 times, most recently from 9b5ddec to bd61f39 Compare December 1, 2023 20:14
@stricklandrbls
Copy link
Collaborator Author

The different highlighting for extending / shortening the byte selection via the editor panel, has been removed. Now, once a multiple byte selection has been made, only those bytes will be highlighted in the viewports. This is regardless of the size of the edited data segment.

@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch 2 times, most recently from bfb0ddb to 9fce048 Compare December 1, 2023 23:14
@scholarsmate scholarsmate force-pushed the byte-highlighting-update branch from 9fce048 to 4aab54a Compare December 4, 2023 14:16
@scholarsmate
Copy link
Contributor

Rebased on the most recent main.

@scholarsmate
Copy link
Contributor

The Search function isn't working properly:

As we navigate using the "seek to next match", we start seeing incorrect matches being highlighted.

Screenshot 2023-12-04 at 09 26 26

It gets worse as we get to the last match.

Screenshot 2023-12-04 at 09 26 06

The warning text is jumbled up.

Screenshot 2023-12-04 at 09 24 17

This is neat though that it can handle overlapping highlghts.

Screenshot 2023-12-04 at 09 25 16

To reproduce, just open package.json and search for Apache. You can see that no changes were made yet.

@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch 2 times, most recently from 43f91c6 to 571eedc Compare December 4, 2023 20:15
@stricklandrbls stricklandrbls mentioned this pull request Dec 4, 2023
@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch 2 times, most recently from 8e3f11b to 9d899c9 Compare December 8, 2023 20:38
Copy link
Contributor

@scholarsmate scholarsmate left a comment

Choose a reason for hiding this comment

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

+1

@@ -459,11 +459,17 @@ export class DataEditorClient implements vscode.Disposable {
case MessageCommand.undoChange:
await undo(this.omegaSessionId)
await this.sendChangesInfo()
this.panel.webview.postMessage({
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: I don't quite know enough to understand these additions, and to a newbie it seems like one is clearing changes right after the changes are sent, which is slightly confusing. Can you tell me more?

Copy link
Collaborator Author

@stricklandrbls stricklandrbls Dec 20, 2023

Choose a reason for hiding this comment

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

I'm on github mobile and have to poke around to see what this is referencing. I'll get back to you soon.

This is because the clear changes command will clear the changes that were made in the data editor and in turn clear the data stores that the byte highlighting is derived from.

The naming convention does seem a bit confusing but the this.sendChangesInfo() is sending "changes" in regards to the difference in changes made from Data Editor viewport edits and the associated file on this. Whereas, the webview message clearChanges clears uncommitted changes / edit from a user's selection from within the data editor.

I think they could both use a bit more expressive names: sendUpdatedFileInfo and clearUnsavedActivity perhaps.

Copy link
Contributor

@arosien arosien left a comment

Choose a reason for hiding this comment

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

👍

although i have a quick question posted

@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch 2 times, most recently from f063e9b to 11c6dc8 Compare December 21, 2023 03:07
- Added indexable indication array for ByteValues within the viewport displays.
- Created categorical byte indiciations values & CSS selectors.

Closes apache#784
@stricklandrbls stricklandrbls force-pushed the byte-highlighting-update branch from 11c6dc8 to 06c06ae Compare December 21, 2023 20:51
@stricklandrbls stricklandrbls merged commit d7f7088 into apache:main Dec 21, 2023
21 checks passed
@stricklandrbls stricklandrbls deleted the byte-highlighting-update branch June 26, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data editor Issues related to the Data Editor capability enhancement New feature or request typescript
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Continue improving persisting selections in viewports
4 participants