Changeset 11903


Ignore:
Timestamp:
Apr 7, 2009, 10:10:53 AM (10 years ago)
Author:
gb
Message:

Try to work around the confusion in #/replaceCharactersInRange:withString:
by adding more confusion. This method -should- assume that the caller
has done #/beginEditing on the textstorage and will do #/endEditing
at some point in the future, but it calls Hemlock code that asserts
that editing is not in progress. (Some of our own methods may call
this method without a preceding #/beginEditing.) So, to kludge around
this, note the edit count on the texstorage before modifying the buffer
and call #/endEditing until the edit count is 0, do the Hemlock-level
modification, then restore the edit count (by calling #/beginEditing
to raise the edit count back to the level it had on entry.)

This is a total hack (and may break something somewhere), but it keeps
this code from generating a spurious assertion failure and allows foreign
code to modify the buffer; for a good time, try "ctrl-q option-e e" on
a US keyboard. (This exposes other problems with non-ASCII characters
in lisp buffers; it's not clear that their syntax attributes are reasonable.)

In #/paste, assume that #/replaceCharactersInRange:withString: isn't broken,
and bracket the call to that method with #/beginEditing / #/endEditing
calls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/cocoa-editor.lisp

    r11732 r11903  
    785785         (view (front-view-for-buffer buffer)))
    786786    (when view
    787       (hi::handle-hemlock-event view #'(lambda ()
    788                                          (hi:paste-characters position length
    789                                                               lisp-string))))))
     787      (let* ((edit-count (slot-value self 'edit-count)))
     788        (dotimes (i edit-count) (#/endEditing self))
     789        (hi::handle-hemlock-event view #'(lambda ()
     790                                           (hi:paste-characters position length
     791                                                                lisp-string)))
     792        (dotimes (i edit-count)
     793          (#/beginEditing self))))))
    790794
    791795(objc:defmethod (#/setAttributes:range: :void) ((self hemlock-text-storage)
     
    29602964          ;; asserts that editing isn't in progress.  Once that's
    29612965          ;; fixed, this should be fixed as well.
    2962           #+not-broken (#/beginEditing textstorage)
     2966          (#/beginEditing textstorage)
    29632967          (#/replaceCharactersInRange:withString: textstorage selectedrange string)
    2964           #+not-broken (#/endEditing self))))))
     2968          (#/endEditing self))))))
    29652969
    29662970
Note: See TracChangeset for help on using the changeset viewer.