  A search for the electroweak production of pairs of charged sleptons or
charginos decaying into two-lepton final states with missing transverse
momentum is presented. Two simplified models of $R$-parity-conserving
supersymmetry are considered: direct pair-production of sleptons
($\tilde{\ell}\tilde{\ell}$), with each decaying into a charged lepton and a
$\tilde{\chi}_1^0$ neutralino, and direct pair-production of the lightest
charginos $(\tilde{\chi}_1^\pm\tilde{\chi}_1^\mp)$, with each decaying into a
$W$-boson and a $\tilde{\chi}_1^0$. The lightest neutralino
($\tilde{\chi}_1^0$) is assumed to be the lightest supersymmetric particle
(LSP). The analyses target the experimentally challenging mass regions where
$m(\tilde{\ell})-m(\tilde{\chi}_1^0)$ and
$m(\tilde{\chi}_1^\pm)-m(\tilde{\chi}_1^0)$ are close to the $W$-boson mass
(`moderately compressed' regions). The search uses 139 fb$^{-1}$ of
$\sqrt{s}=13$ TeV proton-proton collisions recorded by the ATLAS detector at
the Large Hadron Collider. No significant excesses over the expected background
are observed. Exclusion limits on the simplified models under study are
reported in the ($\tilde{\ell},\tilde{\chi}_1^0$) and
($\tilde{\chi}_1^\pm,\tilde{\chi}_1^0$) mass planes at 95% confidence level
(CL). Sleptons with masses up to 150 GeV are excluded at 95% CL for the case of
a mass-splitting between sleptons and the LSP of 50 GeV. Chargino masses up to
140 GeV are excluded at 95% CL for the case of a mass-splitting between the
chargino and the LSP down to about 100 GeV.
