SCM: Support past commit message navigation#107619
Conversation
|
@meganrogge We add |
joaomoreno
left a comment
There was a problem hiding this comment.
At first glance, there is quite some work to do here.
The SCMInput's API should really not change much, adding 3 methods to it seems like an overkill. Could we reuse the HistoryNavigator here?
Also, that addition of build/monaco/api.js seems a mistake, let's remove it.
b7374d0 to
63a04ce
Compare
|
@joaomoreno There are a few issues with the new approach:
For example, let's say I have 3 messages successfully committed. message 1 and I can navigate between them. so i'm typing message 4 when I want to reference then what will be in the history at that time is: message 1 or I return to message 4 and change it completely to hello. what i'll see in the history if I go back through it is: message 1 even though message 4 was not a successful commit I'm not sure how to solve this. what I'd want to see is: message 1 do you agree this would be the expectation? also, on the first pass through it's doing a strange thing with the order. on the way back down it's resolved and appears to store them in the correct order when debugged. |
We'd save the value when (1) the inbox box changes in interesting ways (the
Absolutely! You can always change the |
4d55dd1 to
defef6a
Compare
|
@joaomoreno this is working now except:
|
A few other issues I see:
Idea: why not allowing the history to store the empty string as a value? Raising that restriction will let you fix issue (1) above and will let you just store strings, instead of storing strings and booleans in history. |
d691539 to
3174834
Compare
|
@joaomoreno |
ae43d14 to
814f8e3
Compare
|
@meganrogge First off: this was a hard work item. Even I failed to grasp the complexity of the issue. As I reviewed it this time I decided to go ahead and finalize it by making some changes. You did a good job, but ultimately were hitting issues of the current HistoryNavigator. Let me explain. The current HistoryNavigator is weird. It lets the navigation go out of its bound, which is really nasty and misaligns with the fact that we want to store the current editing value as the last of the history. This is the reason why you couldn't simply store strings. It was also the source of bugs like having to press I took the time to write a new HistoryNavigator2 which never lets the cursor go outside a history. It's implemented as a linked list, so capping its size is cheap. The caveat with it is that it doesn't remove duplicates, since I didn't think that was too important. But feel free to add that capability to HistoryNavigator2 if you think it is, should be pretty easy. Ultimately, it lets us just store strings, while keeping our code much smaller and easy to reason about. Please give it a look, try it out and let me know what you think. Some notes on the work:
As you test this, remember to try it in a new workspace, since the storage in your test workspace contains the array of tuples, so the code will break, since it expects an array of strings. Overall great work, you really pushed this forward! 👏 |
…t input is last in history
5a70ac4 to
44bdd44
Compare
probably by using the |
|
@joaomoreno it's now working as expected. I'll wait for your final sign-off to merge it. |
There was a problem hiding this comment.
Your fix wasn't quite there yet. That change broke the save on reload functionality. The right fix here would be to call replaceLast on the history only if the user is currently typing their message (isAtEnd() === true). My bad! 🙈 I've pushed those changes.
I've tested it more and feels great, what do you think? Merging this in! 💪 Further fixes can land in master directly, if necessary.
| this.storageService.onWillSaveState(e => { | ||
| if (e.reason === WillSaveStateReason.SHUTDOWN) { | ||
| this.historyNavigator.replaceLast(this._value); | ||
| this.historyNavigator.replaceLast(this.historyNavigator.last()); |
There was a problem hiding this comment.
No I don't think this is correct. This code does nothing since it ends up doing this.tail.value = this.tail.value...
Plus it breaks functionality: (1) type something in the commit box, (2) reload 🐛 message is not there.
|
|
||
| constructor(history: readonly T[], private capacity: number = 10) { | ||
| if (history.length <= 1) { | ||
| if (history.length < 1) { |
* logging prior commit messages * Logging prior commit messages * Logging prior commit messages * now works in forward and backward directions * reset index on empty input * cleaning up code * introduce historyNavigator, working but not persisting on window reload * introduce historyNavigator, working but not persisting on window reload * add history * saves search entries on window reload but doesn't save last typed message in input box * save input * change where the save occurs * working * add remove last method * now replaces most recent input * remove check for null value * now at least lets you see most recent commit * before adding objects * add scmi value class * add scmi value class * new commit * fix removal / insertion order * change function modifiers * working correctly * change conditional * undo inadvertant changes * Update README.md * fix tricky bug * working and removed unnecessary conditional * fix another bug * make elements private again * change order of save * now working as expected, about to add context keys * hook up context keys * save on shutdown * improve variable name * disable show prior/next commit when there's no history and ensure that input is last in history * formatting * add new history navigator * fix bad == * rename scm input history methods * adopt HistoryNavigator2 in SCMInput * remove unnecessary method * revert history.ts * 💄 * change size of history required to be valid * revert change * on reload, display latest input * remove rogue console.log * fix issue with saving uncommitted message Co-authored-by: João Moreno <[email protected]>

This PR addresses this feature request