Discussion:
Crash with composition and active auto completion on OS X
Mike Lischke
2014-03-24 10:57:39 UTC
Permalink
Hey Neil,

I got a bug report with a crash on OS X when auto completion is active and you type something that needs composition (e.g. start with a backtick then press space). It crashes in ScintillaBase::AddCharUTF, because the check for isFillUp unconditionally takes *s. s is NULL in this situation. My question is now if that is just a bug there, i.e. does AddCharUTF have to work properly even with a NULL string or is my approach wrong to remove text after composition ended?

The empty string comes from ScintillaView.mm removeMarkedText. This code path works fine usually, just not when auto completion is active at the same time, which leads me to the assumption that AddCharUTF is supposed to cope with a NULL string.

Mike
--
www.soft-gems.net
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Neil Hodgson
2014-03-24 22:48:02 UTC
Permalink
Post by Mike Lischke
I got a bug report with a crash on OS X when auto completion is active and you type something that needs composition (e.g. start with a backtick then press space). It crashes in ScintillaBase::AddCharUTF, because the check for isFillUp unconditionally takes *s. s is NULL in this situation.
On other platforms, len>0 and s!=NULL always.
Post by Mike Lischke
My question is now if that is just a bug there, i.e. does AddCharUTF have to work properly even with a NULL string or is my approach wrong to remove text after composition ended?
The empty string comes from ScintillaView.mm removeMarkedText.
Why does removeMarkedText call InsertText(@"")? That calls AddCharUTF which is quite complex. It would be simpler and have fewer side-effects to replace the start of removeMarkedText with

[ScintillaView directCall: mOwner
message: SCI_DELETERANGE
wParam: mMarkedTextRange.location
lParam: mMarkedTextRange.length];

Deleting a range occurs 3 times in ScintillaView.mm so should be bundled into a method.

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Neil Hodgson
2014-03-25 13:01:08 UTC
Permalink
Cocoa's implementation of composition is unlikely to work well with autocompletion. Say the user has typed "f" and initiated autocompletion producing a list containing [fopen, föx, fübar]. The user wants "föx" so types a "¨" which is shown with the composition underline. Since the "¨" went through the normal AddCharUTF, it is sent through to the autocompletion list which can not find any strings starting with "f¨" and will give up and close the autocompletion before the user completes the "fö" by typing "o".

There are different ways to handle this but the simplest appears to be to not send composition characters (the "¨") through to the autocompletion code, only finished characters ("ö").

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Neil Hodgson
2014-03-26 00:38:35 UTC
Permalink
Committed change to use delete range instead of inserting an empty string.
http://sourceforge.net/p/scintilla/code/ci/bfa91ad22c92d00448b99e968eef9bf3e72cb1c2/

Protect against calling AddCharUTF with an empty insertion.
http://sourceforge.net/p/scintilla/code/ci/b8e34da7096370115321b4b39d2dd71f08befe87/

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Mike Lischke
2014-03-27 15:05:05 UTC
Permalink
Excellent, thanks Neil.
Post by Neil Hodgson
Committed change to use delete range instead of inserting an empty string.
http://sourceforge.net/p/scintilla/code/ci/bfa91ad22c92d00448b99e968eef9bf3e72cb1c2/
Protect against calling AddCharUTF with an empty insertion.
http://sourceforge.net/p/scintilla/code/ci/b8e34da7096370115321b4b39d2dd71f08befe87/
Mike
--
www.soft-gems.net
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...