Merge pull request #332 from sdedic/sdedic/osgi_compendium

Updated references to osgi.cmpn-4.2.jar in project files, followup to NETBEANS-105
diff --git a/editor.lib2/src/org/netbeans/api/editor/caret/EditorCaret.java b/editor.lib2/src/org/netbeans/api/editor/caret/EditorCaret.java
index ac3b564..64ffd85 100644
--- a/editor.lib2/src/org/netbeans/api/editor/caret/EditorCaret.java
+++ b/editor.lib2/src/org/netbeans/api/editor/caret/EditorCaret.java
@@ -1889,9 +1889,18 @@
                 newAtomicDoc.addAtomicLockListener(listenerImpl);
             }
 
+            // #269262 when IME is used, deinstall and install method is invoked
+            // so in such case, the existing position shoud be used
+            // because newDoc.StartPosition() may be an incorrect position
+            CaretInfo lastCaret = getLastCaret();
+            Position dotPos = lastCaret.getDotPosition();
+            if (dotPos == null) {
+                dotPos = newDoc.getStartPosition();
+            }
+
             // Set caret to zero position upon document change (DefaultCaret impl does this too)
             runTransaction(CaretTransaction.RemoveType.REMOVE_ALL_CARETS, 0,
-                    new CaretItem[] { new CaretItem(this, newDoc.getStartPosition(), Position.Bias.Forward,
+                    new CaretItem[] { new CaretItem(this, dotPos, Position.Bias.Forward,
                             null, Position.Bias.Forward ) }, null);
             
             // Leave caretPos and markPos null => offset==0
@@ -1923,6 +1932,11 @@
                         } finally {
                             doc.readUnlock();
                         }
+                    } else {
+                        // #269262 avoid that update() is not invoked
+                        synchronized (listenerList) {
+                            caretUpdatePending = false;
+                        }
                     }
                 }
             };