Happy New Year all!

Following up on the problem with \autoinsertnextspace (https://mailman.ntg.nl/pipermail/ntg-context/2022/107111.html) and the new \autoinsertedspace that came from that report, I see that there is still a problem, or perhaps a problem again after it was previously repaired.

The following code, run under the latest (and recent previous) version, produces an incorrect result, with no space inserted where expected in many cases. As the first examples after \starttext show, the problem appears to be with \autoinsertedspace, but perhaps I am using it incorrectly in the macro as well.

\starttexdefinition unexpanded BD
  \dodoublegroupempty
  \doBD
\stoptexdefinition

\starttexdefinition doBD #1#2
   \removeunwantedspaces\ % insert a space
   (
   \ifsecondargument
       #1|–|#2
   \else\iffirstargument
       #1–
   \else
       {\red I NEED A DATE OR DATES!}
   \fi\fi
   )
   \autoinsertedspace
\stoptexdefinition

\tt

\starttext
This\autoinsertedspace fails unexpectedly with autoinsertedspa
ce.\par
This\autoinsertedspace \emph{fails unexpectedly} with autoinsertedspace.\par
This\autoinsertnextspace works with autoinsertnextspace.\par
This\autoinsertnextspace \emph{fails} as expected with autoinsertnextspace.\par
Saussure\BD{1857}{1913} works.\par
Saussure \BD{1857}{1913} \emph{works}.\par
Saussure \BD{1857}{1913}. Works.\par
Chomsky\BD{1928} fails with LMTX, works with MkIV.\par

Chomsky \BD{1928} \emph{fails with LMTX, works with MkIV}.\par
Chomsky \BD{1928}. Works.\par
\BD blah\par
\contextversion\ \texenginename
\stoptext


--
Rik