Donald Trump’s choice of Indiana Governor Mike Pence as his running mate brought a smile to my face. And not for the reason you may think. When I heard Pence described as a Tea Party acolyte, a “movement conservative” and “evangelical favorite” intended to shore up Trump’s Republican base, I recalled that Pence had not always faithfully towed his party’s line.

When I went to jail for three months in the summer of 2005 to protect the First Amendment by refusing to identity my sources in a case involving the leak of a CIA official’s name, few senators or Members of Congress defended me.  The government was able to hold me in contempt of court for refusing to name names because there was no Federal law that specifically protected reporters from being hauled before grand juries in Federal investigations and being forced to testify in court. After emerging from jail, I was surprised when Rep. Pence called me to discuss the case at his office on Capitol Hill.

Though we had never met, Rep. Pence told me that he had followed the case closely. He thought it was an outrage that I had been jailed for protecting my sources despite the fact that I had never written a word about Valerie Plame, the CIA official whose identity was compromised (though not, as critics of the Iraq war charged, because her husband had criticized President Bush’s decision to invade Iraq). Forcing reporters to reveal their sources, Pence told me, “chills reporting of the news and restricts the free flow of information to the public.” Intimidating reporters, he said, would limit the ability of the reporters to act as independent watchdogs on government waste, fraud and abuse.

He said that he was particularly interested in guaranteeing the independence of a free, unfettered press because before his election he had hosted a syndicated radio talk show and a political TV show on Sunday mornings in Indianapolis. He promised to do what he could to ensure that other reporters were not jailed or subjected to unwarranted government investigations into their reporting sources and methods unless grave issues of national security were at stake.

After emerging from jail, I was surprised when Rep. Pence called me to discuss the case at his office on Capitol Hill.

True to his word, Mr. Pence introduced the “Free Flow of Information Act” with Democratic Rep. Rick Boucher of Virginia. “As a conservative who believes in limited government,” he said after reintroducing the legislation which failed the first time he proposed it, “I believe the only check on government power in real time is a free and independent press.”

Pence’s bill was far from perfect. The language describing when reporters would be forced to reveal sources on national security grounds was far broader than I would have liked. First Amendment purists attacked it then and now as being too loose, noting that most politically sensitive cases ensnaring reporters and classified information involve “national security” information.

Yet writing in The New Yorker, even Steve Coll, the dean of the Graduate School of Journalism at Columbia University who is no fan of Mr. Pence’s, called the legislation “politically plausible…” and “much, much better than the status quo.” The bill was also endorsed by the Society of Professional Journalists.

Though 49 states and the District of Columbia have taken steps to reinforce the right of journalists to protect confidential sources by specifying when journalists can withhold the identity of sensitive sources from court or government scrutiny, there is still no comparable protection at the Federal level. The Bush administration staunchly opposed the Pence bill.

Nor did the situation improve under President Obama, who vowed to run the most “transparent” administration in history but wound up ignoring or intimidating reporters and opposing Pence’s bill and similar measures.  While promising to support a media shield bill before his election, Obama objected to bills that would have provided that protection. His Justice Department, moreover, used the Espionage Act of 1917 to punish government whistleblowers who leaked to journalists more than all previous presidential administrations combined.

James Risen, my former colleague at New York Times, who risked jail rather than cooperate with the government, called Obama’s administration “the greatest enemy of press freedom in a generation.”

Former Attorney General Eric Holder supported a media shield law only after his Justice Department was caught violating the civil and reporting rights of James Rosen, my Fox colleague.

While Mike Pence did not succeed in providing the shield that reporters still need, he never stopped trying. So I found it doubly ironic that he has now agreed to share a ticket with a presidential candidate who considers reporters “the most dishonest people" he's ever met. While I continue to oppose Pence's religious liberty bill and almost every other part of what I consider an extreme domestic social agenda, he and I managed to find common ground on this fundamental guarantor of democracy: a free press.                                             

Judith Miller, a Fox News contributor, is an award-winning writer and author, and an adjunct fellow at the Manhattan Institute. The author of several books, her latest is "The Story: A Reporter's Journey" (Simon & Schuster, April 7, 2015) now available in paperback. Follow her on Twitter @JMFreeSpeech.