code review comments. detect xml mode in Editor getModeForSelection(). use CodeMirror.innerMode() when searching for tagName.