fix/FEN import ignores side to move#3117
Merged
veloce merged 2 commits intoMay 6, 2026
Merged
Conversation
veloce
reviewed
May 6, 2026
| setup, | ||
| ignoreImpossibleCheck: true, | ||
| ); | ||
| final castlingRights = IMap({ |
Contributor
There was a problem hiding this comment.
this logic could be factored out in a private method.
| final state = container.read(boardEditorControllerProvider(null)); | ||
| expect(state.sideToPlay, Side.black); | ||
| }); | ||
|
|
Contributor
There was a problem hiding this comment.
Another test would be useful to test the castling rights logic.
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.
Fix: Board editor FEN paste ignores side to move (and castling rights)
Root cause
loadFen in BoardEditorController only called _updatePosition, which updates piece positions but leaves all other state (sideToPlay, castlingRights, enPassantSquare, etc.) unchanged. Pasting a FEN where black is to move had no effect on the side to play.
Fix
loadFen now distinguishes between two cases:
Test added
A new test Pasting FEN with black to move correctly sets side to play was added to test/view/board_editor/board_editor_screen_test.dart. It pastes a full FEN with black to move and verifies that sideToPlay is correctly set to Side.black after the paste.
Note
The FEN parsing logic in loadFen (for the full FEN case) is similar to the inline logic in build(). Should this be extracted into a shared helper method, or is the current duplication acceptable?
In the videos i used this FEN: r1bqkbnr/pppp1ppp/2n5/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R b KQkq - 2 3
Bug
https://github.com/user-attachments/assets/28160b2f-c85f-4f4b-8e19-2551a86c6771
Fixed
https://github.com/user-attachments/assets/320e4e4e-9a70-4b14-9ea1-b84b444c5330
Fixes: #3111