remember file selection per-folder

avoids losing file selection when
accidentally changing to another folder
This commit is contained in:
ed 2025-02-08 15:18:07 +00:00
parent 3582a1004c
commit c7db08ed3e

View file

@ -7835,7 +7835,7 @@ var treectl = (function () {
r.gentab = function (top, res) { r.gentab = function (top, res) {
var nodes = res.dirs.concat(res.files), var nodes = res.dirs.concat(res.files),
html = mk_files_header(res.taglist), html = mk_files_header(res.taglist),
sel = r.lsc === res ? msel.getsel() : [], sel = msel.hist[top],
ae = document.activeElement, ae = document.activeElement,
cid = null, cid = null,
plain = [], plain = [],
@ -7946,10 +7946,7 @@ var treectl = (function () {
apply_perms(res); apply_perms(res);
fileman.render(); fileman.render();
} }
if (sel.length) msel.loadsel(top, sel);
msel.loadsel(sel);
else
msel.origin_id(null);
if (cid) try { if (cid) try {
ebi(cid).closest('tr').focus(); ebi(cid).closest('tr').focus();
@ -8831,6 +8828,7 @@ var msel = (function () {
var r = {}; var r = {};
r.sel = null; r.sel = null;
r.all = null; r.all = null;
r.hist = {};
r.so = null; // selection origin r.so = null; // selection origin
r.pr = null; // previous range r.pr = null; // previous range
@ -8879,10 +8877,14 @@ var msel = (function () {
} }
}; };
r.loadsel = function (sel) { r.loadsel = function (vp, sel) {
if (!sel || !r.so || !ebi(r.so)) if (!sel || !r.so || !ebi(r.so))
r.so = r.pr = null; r.so = r.pr = null;
if (!sel)
return r.origin_id(null);
r.hist[vp] = sel;
r.sel = []; r.sel = [];
r.load(); r.load();
@ -8914,6 +8916,11 @@ var msel = (function () {
thegrid.loadsel(); thegrid.loadsel();
fileman.render(); fileman.render();
showfile.updtree(); showfile.updtree();
if (r.sel.length)
r.hist[get_evpath()] = r.sel;
else
delete r.hist[get_evpath()];
}; };
r.seltgl = function (e) { r.seltgl = function (e) {
ev(e); ev(e);