fix(cli): reset track selection on disc rescan to prevent TypeError#15
Merged
Conversation
When the user rescans the disc (menu option 2) after having visited the track selection menu (option 4), the cached @selection in CliTracklist becomes stale. If the new disc has fewer tracks, the old track numbers cause @disc.getLengthSector(track) to return nil, producing: TypeError: nil can't be coerced into Float Fix by recreating @cliTracklist on rescan (same pattern as CliDisc#refreshDisc which creates Disc.new()). The new instance lazily initializes @selection from the current disc's track list, discarding any stale state. This mirrors the GTK interface (GtkDisc#refreshDisc) which resets @selection = [] on every refresh. Also add spec verifying that a freshly created CliTracklist returns the current disc's track list even when a previous instance had a different track count.
When the user selects option 2 (rescan drive) in the main menu, scan errors (e.g. no disc in drive) were silently swallowed: @cliDisc.show() stores the error in @cliDisc.error but never displays it, unlike prepare() which calls showError() afterward. Add the missing showError() call after @cliDisc.show() in the loopMainMenu option 2 branch, matching the existing prepare() pattern. Also add a new spec file (spec/cli/commandLineInterface_spec.rb) with a test case that verifies scan errors are displayed.
Owner
Author
修正: リセキャン(オプション 2)のエラー黙殺問題に対応問題loopMainMenu の when 2 分岐で @cliDisc.show() を呼び出した後、スキャン失敗時のエラーがユーザーに表示されていませんでした。起動時のスキャン (prepare()) では showError() 呼び出しがありましたが、リセキャン時の同じパスでは欠落していました。ユーザーは空行だけを見てスキャンの成否を判断できません。 修正when 2 に showError(@cliDisc.error) unless @cliDisc.error.nil? を追加。prepare() と同じパターンです。 テストspec/cli/commandLineInterface_spec.rb を新規作成。モック化した CliDisc がエラー [:noDiscYet, "3"] を返すシナリオで、showError が標準出力にメッセージを出力することを検証。 検証
|
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.
When the user rescans the disc (menu option 2) after having visited the track selection menu (option 4), the cached @selection in CliTracklist becomes stale. If the new disc has fewer tracks, the old track numbers cause @disc.getLengthSector(track) to return nil, producing:
TypeError: nil can't be coerced into Float
Fix by recreating @cliTracklist on rescan (same pattern as CliDisc#refreshDisc which creates Disc.new()). The new instance lazily initializes @selection from the current disc's track list, discarding any stale state.
This mirrors the GTK interface (GtkDisc#refreshDisc) which resets @selection = [] on every refresh.
Also add spec verifying that a freshly created CliTracklist returns the current disc's track list even when a previous instance had a different track count.