I have an A515-51G-58VH that has
no problems with charging the battery while being used to browse the web, edit documents, etc.
The problem is
when I start to play games or do some heavy work in general: the battery stops charging,
even though the cable was never unplugged. The issue is that performance drops a lot
when I need it the most, making it almost impossible to do some performance-heavy tasks.
If I unplug the cable and plug it in again, it charges the battery for a few seconds (20/30 seconds max) and then stops charging.
Close the game -> battery starts charging
I've had this model since 2018 but only have been hit with this issue recently 
What I tried:
- Uninstalling the battery drivers and restarting Windows.
- Pushing the pin at the bottom
- Replacing the battery with a new one
I have not tried replacing the charger; because it works perfectly while not gaming. Apart from being the charger's fault, I have no ideas about what could be causing this.