save "viewed" state in the diff file #50
Replies: 1 comment 1 reply
-
Thanks for the complete description, @jacekkopecky! This use case makes total sense to me. As described in [1], the VS Code Extension API provides a data storage mechanism. However, the "viewed" state would be bound to VS Code, not the file itself. If the file is copied, moved, or opened in a different VS Code instance, the "viewed" state would be lost. On the other hand, the proposed approach avoids the issue I've mentioned because the state is saved in the file itself. I don't a see problem with this approach as long as this feature is an optional thing (enabled with a config) and disabled by default. The user must be fully aware that the file content will be changed and the reason they are changing. Either way, storing the state using Let me know your thoughts. :) [1] https://code.visualstudio.com/api/extension-capabilities/common-capabilities#data-storage |
Beta Was this translation helpful? Give feedback.
-
Motivation
When reviewing code by going through a long-ish diff, especially if I want to jump around, the "viewed" feature of diff2html is very useful to hide files I've reviewed. Sometimes, a bigger review goes on for a few days; it is terrible if I have to restart VSCode in the meantime and lose the "viewed" state. The view also loses its state if the file gets touched externally, or if I accidentally close and then reopen the tab.
Therefore, I've been thinking about saving the state somewhere. I don't know much about VSCode extensions yet so I don't know if they have some kind of information store available. Therefore, I implemented a version that saves the "viewed" state right in the diff file.
Proposed solution
In a diff file, there can be any number of extra lines, provided they don't start with
-
/+
/space. My version uses a line like this:viewed e8 (hex bitmap)
The syntax is:
"viewed" SP <hexBitmap> SP <comment>
The comment can be anything (after the hex bitmap, the rest of the line is ignored).
The hex bitmap is a hexadecimal representation of the boolean array that indicates which files have been viewed. E.g. "e8" means that the first, second, third and fifth files are marked as viewed. (
e8
is 11101000).The "viewed" line can be anywhere in the diff file; by default it's saved at the top of the file because that's fastest to find on load. Hexadecimal was chosen for brevity.
So, two questions for discussion:
Beta Was this translation helpful? Give feedback.
All reactions