"I am worried that if I file bankruptcy "before" a judgement is filed, that the bankruptcy filing won't cover a judgement that occurs after filing. Almost like a debit incurred after filing bankruptcy would not be included. This is confusing me."
You can put your worries to rest.
It doesn't matter whether you file bankruptcy before or after a judgment of foreclosure. Either way, assuming you intend to surrender the property in bankruptcy, you will no longer have the property, any debt you may owe on it is discharged, and you will have no tax liability related to any portion of the debt which is discharged in bankruptcy (i.e., no "deficiency").
I am concerned about some of the responses above because some of the specifics posted in previous answers are state-specific, and may not work exactly the same way in all states (for example, some states do not allow a mortgage holder to place a lien on other property to collect a deficiency on a home after foreclosure, while others do).
But either way -- regardless of which kind of state you live in - in any state - when secured real estate is surrendered to the mortgage holder as part of a bankruptcy proceeding (a) it does not lead to any tax liability due to discharged debt (though I think, theoretically, capital gains could be an issue in extremely rare circumstances - see a tax professional), and (b) the surrender in bankrupcy halts any suits for money judgment that may be in progress at the time of filing and prevents them from being filed subsequent to the bankruptcy filing (that is the effect of the automatic stay); the only judgment that can occur subsequent to the surrender in bankruptcy is judgment of foreclosure (in judicial foreclosure states).
The way that your scenario COULD conceivably come into play is if you do NOT surrender the real estate in bankruptcy and subsequently do not make the payments as agreed so the mortgage holder forecloses. In other words, in Ch 7 you must declare "surrender" as your statement of intention regarding the property, and in Ch 13 the surrender of the property must be written into your Ch 13 Plan. If the property is correctly surrendered in bankruptcy, your worries won't come to pass regardless of the technicalities of your particular state's laws related to foreclosure.
In the past, some attorneys in some states have advised simply "not filing a reaffirmation agreement" and then walking away from the property if you can't continue to make the payments. I think some recent Appeals decisions have suggested that post-BAPCPA this will not any longer be an option (although it has not yet been taken up by the US Supreme Court, so not all Federal Circuits are yet under the same precedent-setting decisions).
For what its worth -- noting that I am NOT an attorney.