corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmke...@apache.org
Subject incubator-corinthia git commit: Place cursor properly after deleting an item
Date Fri, 06 Mar 2015 08:50:43 GMT
Repository: incubator-corinthia
Updated Branches:
  refs/heads/master dd3e2374e -> 7ea85b139


Place cursor properly after deleting an item

When an outline item - either a section, figure, or table - is deleted,
ensure the position is in a valid place with respect to movement (i.e. a
position that the user would normally be allowed to navigate manually).
This is necessary so that we get a valid rect for the cursor, and avoids
an ugly affect whereby the cursor rect would be to the far left of the
screen, and taking up the entire height of the document.


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/7ea85b13
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/7ea85b13
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/7ea85b13

Branch: refs/heads/master
Commit: 7ea85b1396b626529eed74144be9d1867d91bf93
Parents: dd3e237
Author: Peter Kelly <peter@uxproductivity.com>
Authored: Fri Mar 6 15:50:13 2015 +0700
Committer: Peter Kelly <peter@uxproductivity.com>
Committed: Fri Mar 6 15:50:13 2015 +0700

----------------------------------------------------------------------
 Editor/src/Outline.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7ea85b13/Editor/src/Outline.js
----------------------------------------------------------------------
diff --git a/Editor/src/Outline.js b/Editor/src/Outline.js
index e021d23..9812041 100644
--- a/Editor/src/Outline.js
+++ b/Editor/src/Outline.js
@@ -1102,7 +1102,19 @@ var Outline_scheduleUpdateStructure;
             }
         });
 
+        // Ensure the cursor or selection start/end positions are valid positions that the
+        // user is allowed to move to. This ensures we get an accurate rect for each position,
+        // avoiding an ugly effect where the cursor occupies the entire height of the document
+        // and is displayed on the far-left edge of the editing area.
+        var selRange = Selection_get();
+        if (selRange != null) {
+            var start = Position_closestMatchForwards(selRange.start,Position_okForMovement);
+            var end = Position_closestMatchForwards(selRange.end,Position_okForMovement);
+            Selection_set(start.node,start.offset,end.node,end.offset);
+        }
+
         scheduleUpdateStructure();
+        PostponedActions_add(Cursor_ensureCursorVisible);
         PostponedActions_add(UndoManager_newGroup);
     }
 


Mime
View raw message