The Australian triumphed 6-4 1-6 6-3 after nearly two hours on court to extend her winning streak on clay to 13 matches.
Barty will face reigning French Open champion Iga Swiatek in the next round, the 19-year-old having eased past Laura Siegemund 6-3 6-3 in a contest where she failed to take 10 match points before getting over the line.
Barty endured a more troubled contest with Zidansek, landing just 51 per cent of her first serves.
Zidansek lost the opener after a wayward forehand at 4-4 but was authoritative in the second as she won a set against a top-10 player for the first time.
However, a series of errors early in the decider allowed world No.1 Barty to open up a lead she did not relinquish. Barty was champion at Roland Garros in 2019 but skipped last year's Paris grand slam, so the clash with Swiatek will pit together the two most recent French Open winners.
"[It was] a really tough match," Barty said after edging out Zidansek. "I felt my margins were a little bit off. I made a lot of errors. I think I was missing in the right way, but still just a foot or two here or there makes a big difference. I felt like there were probably too many loose ones for me today.
"I don't think there was a lot in it by any means. We had a lot of close games in the first set, early in the second set. In the third, as well, there were a lot of close games. I think the response early in the third was good. I was a bit more aggressive, was able to bring the match back on my terms."
Petra Kvitova set up a meeting with Veronika Kudermetova, who knocked out defending champion Kiki Bertens, after overcoming long-time rival Angelique Kerber 6-4 7-5.
Kerber got the opening break in each set, only to drop serve in the next game, with Kvitova ultimately rewarded for powerful hitting as she ended the contest with 33 winners to her opponent's 14.
"I served very well, especially in the important points," Kvitova, who leads the head-to-head record 8-6, said.
"I think we really played very well. She even served very well, as well. It was tough to attack her serve."
No.15 seed Johanna Konta suffered a straight-sets loss to Anastasija Sevastova, while Ons Jabeur fought back to beat Sloane Stephens.