]> gitweb.factorcode.org Git - factor.git/commitdiff
Don't add useless edits
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 28 Jan 2009 18:11:45 +0000 (12:11 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 28 Jan 2009 18:11:45 +0000 (12:11 -0600)
basis/documents/documents-tests.factor
basis/documents/documents.factor

index a044a2d2552bc6ae603574b86389ca201dd8b767..41b4c5de677a74a192fc85b8a439fcd53a69fa2b 100644 (file)
@@ -130,3 +130,11 @@ namespaces tools.test make arrays kernel fry ;
 [ ] [ "d" get redo ] unit-test
 
 [ "Goodbye, world." ] [ "d" get doc-string ] unit-test
+
+[ ] [ <document> "d" set ] unit-test
+
+[ ] [ "d" get clear-doc ] unit-test
+
+[ ] [ "d" get clear-doc ] unit-test
+
+[ 0 ] [ "d" get undos>> length ] unit-test
\ No newline at end of file
index 95f7ad10da3344657f8899fa3ff29b8bc4e1607f..427874c64fda43c0d0cdc76a8a3d8bbb9dc9136a 100644 (file)
@@ -131,13 +131,15 @@ PRIVATE>
     ] if ;
 
 :: set-doc-range ( string from to document -- )
-    string string-lines :> new-lines
-    new-lines from text+loc :> new-to
-    from to document doc-range :> old-string
-    old-string string from to new-to <edit> document add-undo
-    new-lines from to document value>> (set-doc-range)
-    document notify-connections
-    new-to document update-locs ;
+    from to = string empty? and [
+        string string-lines :> new-lines
+        new-lines from text+loc :> new-to
+        from to document doc-range :> old-string
+        old-string string from to new-to <edit> document add-undo
+        new-lines from to document value>> (set-doc-range)
+        document notify-connections
+        new-to document update-locs
+    ] unless ;
 
 : change-doc-range ( from to document quot -- )
     '[ doc-range @ ] 3keep set-doc-range ; inline