diff --git a/src/environment/windows_win32.go b/src/environment/windows_win32.go index 9253b436..cafa701f 100644 --- a/src/environment/windows_win32.go +++ b/src/environment/windows_win32.go @@ -108,9 +108,9 @@ func queryWindowTitles(processName, windowTitleRegex string) (string, error) { // The error is not checked because if EnumWindows is stopped bofere enumerating all windows // it returns 0(error occurred) instead of 1(success) // In our case, title will equal "" or the title of the window anyway - _ = enumWindows(cb, 0) + err := enumWindows(cb, 0) if len(title) == 0 { - return "", errors.New("no matching window title found") + return "", errors.New("no matching window title found\n" + err.Error()) } return title, nil } diff --git a/src/segments/spotify_windows.go b/src/segments/spotify_windows.go index 005a09b2..443bcaad 100644 --- a/src/segments/spotify_windows.go +++ b/src/segments/spotify_windows.go @@ -9,11 +9,11 @@ import ( func (s *Spotify) Enabled() bool { // search for spotify window to retrieve the title // Can be either "Spotify xxx" or the song name "Candlemass - Spellbreaker" - windowTitle, err := s.env.QueryWindowTitles("spotify.exe", "^(Spotify.*)|(.*\\s-\\s.*)$") + windowTitle, err := s.env.QueryWindowTitles("spotify.exe", `^(Spotify.*)|(.*\s-\s.*)$`) if err == nil { return s.parseSpotifyTitle(windowTitle, " - ") } - windowTitle, err = s.env.QueryWindowTitles("msedge.exe", "^(Spotify.*)") + windowTitle, err = s.env.QueryWindowTitles("msedge.exe", `^(Spotify.*)`) if err != nil { return false } diff --git a/src/segments/spotify_windows_test.go b/src/segments/spotify_windows_test.go index 02a18801..670b0f25 100644 --- a/src/segments/spotify_windows_test.go +++ b/src/segments/spotify_windows_test.go @@ -30,11 +30,17 @@ func TestSpotifyWindowsNative(t *testing.T) { ExpectedEnabled: false, Title: "Spotify premium", }, + { + Case: "Playing - new", + ExpectedString: "\ue602 Demon Hunter - Collapsing (feat. Björn \"Speed\" Strid)", + ExpectedEnabled: true, + Title: `Demon Hunter - Collapsing (feat. Björn "Speed" Strid)`, + }, } for _, tc := range cases { env := new(mock.MockedEnvironment) - env.On("QueryWindowTitles", "spotify.exe", "^(Spotify.*)|(.*\\s-\\s.*)$").Return(tc.Title, tc.Error) - env.On("QueryWindowTitles", "msedge.exe", "^(Spotify.*)").Return("", errors.New("not implemented")) + env.On("QueryWindowTitles", "spotify.exe", `^(Spotify.*)|(.*\s-\s.*)$`).Return(tc.Title, tc.Error) + env.On("QueryWindowTitles", "msedge.exe", `^(Spotify.*)`).Return("", errors.New("not implemented")) s := &Spotify{ env: env, props: properties.Map{},