The Umbral Sight function of the Gloom Stalker Ranger, which is activated when a ranger chooses the Gloom Stalker archetype at level 3, states:
You are also able to avoid creatures who trust darkvision. While
in the dark, you are invisible to any creature that relies on
darkvision to see you in this darkness.
Source: Xanathar's guidep. 42
I read this as saying that as long as the ranger stays in the dark, he remains indefinitely invisible to all creatures who would otherwise be able to see the ranger with darkvision. Even attacking or casting a spell, which normally results in the premature end of an invisibility effect, would not do so in this situation. A Gloom Stalker Ranger could repeatedly attack the melee, never move, and remain invisible. Only a creature with a particular meaning, such as real vision or blind vision, could see the ranger, as long as he remains in darkness.
Is this interpretation correct?