regression: fix a crash if there is no document loaded