This patch is an attempt to fix bug #1571405. I moved the code in the CaretListener.insertUpdate method to the event thread using SwingUtilities.invokeLater rather than Utilities.invokeLater so that the CaretListener code always executes after the other document insertion listeners have run. It moves both the caret and promt which may interfere with other listeners (particularly the prompt). The revision only changed the following file: