scratchpad
Closed this issue · 0 comments
azuline commented
sorting debugging
notes on variables:
- sorting is controlled by
cfg.*
globals, which is used inentrycmp
to sort entries. thecfg.*
globals are per-context. cfgsort
controls the sort config across multiple contexts- the
cd
variable is true whenever the directory changes? something like that... it's set to false in special cases prior togoto begin:
notes on special mechanics of cfgsort:
- control flow: we go to
savecurctx
, which does some magic oncfgsort
, and then we go tobegin:
, which does additional magic oncfgsort
cfgsort[CTX_MAX]
is a carrier that sometimes transports the new context's state tobegin:
for that logic to act on it. whencfgsort[curctx] == '0'
, that means we want to use the carried sort and ignore any other logic. this occurs when we switch to a pre-existing context in anorder != null
environment.- note that
\0
is also a default value for each cfgsort. so we hit this when a new session is created.
- note that
- when
cfgsort[curctx] == 'z'
, that means:- we've switched to a new context, and the current context has no sort.
z
converts toc
inbegin:
- we've cd'ed into a directory that's in the
order kv
. the sort flags have been set, and the cfgsort is nullified (aka set toz
) so that it isn't persistent.
- we've switched to a new context, and the current context has no sort.
bugged scenario:
NNN_ORDER
must be set.cfgsort[0] = '0'
,cfg0.reverse = 0
,entrycmpfn = &entrycmp
- set context 1 to
r
cfgsort[0] = 'r'
,cfg0.reverse = 1
,entrycmpfn = &reventrycmp
- create context 2. context 2 should also be
r
.cfgsort[0] = 'r'
,cfgsort[1] = 'r'
,cfg0.reverse = 1
,cfg1.reverse = 1
,entrycmpfn = &reventrycmp
- unset
r
in context 2.cfgsort[0] = 'r'
,cfgsort[1] = 'c'
,cfg0.reverse = 1
,cfg1.reverse = 0
,entrycmpfn = &entrycmp
- switch back to context 1. context 1 should not be
r
.- we hit the "skip ordering on open context carry logic". so we do not change anything
cfgsort[0] = 'r'
,cfgsort[1] = 'c'
,cfg0.reverse = 1
,cfg1.reverse = 0
,entrycmpfn = &entrycmp
- try to set
r
again. no-ops when it should op.cfgsort[0] = 'r'
,cfgsort[1] = 'c'
,cfg0.reverse = 0
,cfg1.reverse = 0
,entrycmpfn = &entrycmp
root cause: &entrycmpfn is out of sync with cfg/cfgsort
soln: restore fn pointers when restoring cfg