Repository navigation
Keep a reloaded command's navigation context and metadata [patch] - #135
Merged
Merged
Conversation
A command that implements ISerializableCommand is rebuilt with its parameterless constructor and DeserializeData, so it came back with no NavigationContext and default metadata (size 1, timestamp at load time). UndoAsync and RedoAsync then stopped navigating after LoadStateAsync. BaseCommand gains an internal RestoreSerializedState hook, which the JSON serializer calls after DeserializeData to put back the saved navigation context and metadata. Fixes #94 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017crwGv42t1FV1Sp9QxoQNe
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #94
Problem
JsonUndoRedoSerializerwritesNavigationContextandMetadatafor every command. On load, only thePlaceholderCommandfallback read them back. A command that implementsISerializableCommandwas rebuilt withActivator.CreateInstanceandDeserializeData, so it kept whatever its parameterless constructor set:As a result,
UndoAsyncandRedoAsyncstopped navigating afterLoadStateAsync.Change
BaseCommandgains aninternal RestoreSerializedState(string? navigationContext, ChangeMetadata metadata), which uses the existingprotected setsetters. The public API does not change.ConvertFromSerializableCommandcalls it afterDeserializeDatawhenever the rebuilt instance is aBaseCommand.Tests
UndoRedoService_LoadStateSerializableCommand_RestoresNavigationContextAndMetadataround-trips anISerializableCommandthroughSaveStateAsyncandLoadStateAsync. It checks the navigation context and every metadata field: change type, affected items, size, timestamp and custom data. It then checks thatUndoAsynccalls the navigation provider withline:42.Assert.AreEqual("line:42", reloaded.NavigationContext).🤖 Generated with Claude Code
https://claude.ai/code/session_017crwGv42t1FV1Sp9QxoQNe
Generated by Claude Code