Fix ordering of doc width adjustment and selection drawing

The selection's width depends on the doc width, so it has to
be drawn after adjusting that.

Issue #2256