refresh CodeMirror instances when switching to tabs, and fix bugs in
widget positioning based on api change.