diff options
| author | Přemysl Eric Janouch <p@janouch.name> | 2021-12-07 20:34:32 +0100 | 
|---|---|---|
| committer | Přemysl Eric Janouch <p@janouch.name> | 2021-12-07 20:34:32 +0100 | 
| commit | 2060da4a8e1710b7ef800498693b619758825d7d (patch) | |
| tree | f41a998db1d13d9b4fade542779170e32682f26d | |
| parent | f5b5cec3407e8e8d52ef50e54d91271e302207ee (diff) | |
| download | nncmpp-2060da4a8e1710b7ef800498693b619758825d7d.tar.gz nncmpp-2060da4a8e1710b7ef800498693b619758825d7d.tar.xz nncmpp-2060da4a8e1710b7ef800498693b619758825d7d.zip | |
Do not jump to beginning after unqueueing
Instead, assume that the whole previously selected range
has been removed, and try to go after or before it accordingly.
| -rw-r--r-- | nncmpp.c | 13 | 
1 files changed, 13 insertions, 0 deletions
| @@ -4378,6 +4378,14 @@ mpd_process_info (const struct strv *data)  {  	char *prev_sel_id  = xstrdup0 (mpd_id_of_pos (g_current_tab.item_selected));  	char *prev_mark_id = xstrdup0 (mpd_id_of_pos (g_current_tab.item_mark)); +	char *fallback_id  = NULL; + +	struct tab_range r = tab_selection_range (g.active_tab); +	if (r.upto >= 0) +	{ +		if (!(fallback_id = xstrdup0 (mpd_id_of_pos (r.upto + 1)))) +			fallback_id = xstrdup0 (mpd_id_of_pos (r.from - 1)); +	}  	mpd_process_info_data (data); @@ -4390,12 +4398,17 @@ mpd_process_info (const struct strv *data)  	{  		g_current_tab.item_selected = mpd_find_pos_of_id (prev_sel_id);  		if (g_current_tab.item_selected < 0) +		{  			g_current_tab.item_mark = -1; +			if (fallback_id) +				g_current_tab.item_selected = mpd_find_pos_of_id (fallback_id); +		}  		app_move_selection (0);  	}  	free (prev_sel_id);  	free (prev_mark_id); +	free (fallback_id);  }  static void | 
