Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 7383)
+++ /CKEditor/trunk/CHANGES.html	(revision 7384)
@@ -57,4 +57,5 @@
 		<li><a href="http://dev.ckeditor.com/ticket/8433">#8433</a> : [IE9] Use W3C event model.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/8691">#8691</a> : [IE] Fix paste invalid HTML crashes browser.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/8345">#8345</a> : [IE] Selection is properly restored after close Link dialog.</li>
 	</ul>
 	<h3>
Index: /CKEditor/trunk/_source/plugins/selection/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/selection/plugin.js	(revision 7383)
+++ /CKEditor/trunk/_source/plugins/selection/plugin.js	(revision 7384)
@@ -265,27 +265,20 @@
 									return;
 
-								// If we have saved a range, restore it at this
+								// Give the priority to locked selection since it probably
+								// reflects the actual situation, besides locked selection
+								// could be interfered because of text nodes normalizing.
+								// (#6083, #6987)
+								var lockedSelection = doc.getCustomData( 'cke_locked_selection' );
+								if ( lockedSelection )
+								{
+									lockedSelection.unlock( 1 );
+									lockedSelection.lock();
+								}
+								// Then check ff we have saved a range, restore it at this
 								// point.
-								if ( savedRange )
+								else if ( savedRange && restoreEnabled )
 								{
-									if ( restoreEnabled )
-									{
-										// Well not break because of this.
-										try
-										{
-											savedRange.select();
-										}
-										catch (e)
-										{}
-
-										// Update locked selection because of the normalized text nodes. (#6083, #6987)
-										var lockedSelection = doc.getCustomData( 'cke_locked_selection' );
-										if ( lockedSelection )
-										{
-											lockedSelection.unlock();
-											lockedSelection.lock();
-										}
-									}
-
+									// Well not break because of this.
+									try { savedRange.select(); } catch (e) {}
 									savedRange = null;
 								}
Index: /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 7383)
+++ /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 7384)
@@ -31,7 +31,17 @@
 				this.focus();
 
+				// Since the insertion might happen from within dialog or menu
+				// where the editor selection might be locked at the moment,
+				// update the locked selection.
+				var selection = this.getSelection(),
+				selIsLocked = selection.isLocked;
+
+				selIsLocked && selection.unlock();
+
 				this.fire( 'saveSnapshot' );
 
 				insertFunc.call( this, evt.data );
+
+				selIsLocked && this.getSelection().lock();
 
 				// Save snaps after the whole execution completed.
@@ -84,9 +94,4 @@
 		if ( CKEDITOR.env.ie )
 		{
-			var selIsLocked = selection.isLocked;
-
-			if ( selIsLocked )
-				selection.unlock();
-
 			var $sel = selection.getNative();
 
@@ -114,7 +119,4 @@
 
 			$sel.createRange().pasteHTML( data );
-
-			if ( selIsLocked )
-				this.getSelection().lock();
 		}
 		else
