This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 227176 - Typinghooks API doesn't work properly
Summary: Typinghooks API doesn't work properly
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 7.3
Hardware: All All
: P2 normal (vote)
Assignee: Milutin Kristofic
URL:
Keywords: API
Depends on:
Blocks:
 
Reported: 2013-03-07 15:52 UTC by Ondrej Brejla
Modified: 2013-03-09 01:57 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Brejla 2013-03-07 15:52:37 UTC
If I have a custom implementation of TypedTextInterceptor and want to use "selection" feature (user selects some text, types e.g. ", and the result is that the selected text is encapsulated by "..") with the caret at the end of the inserted text, it fails on Assertion error (BaseKit:1286).

API says that one can use:

String selection = context.getReplacedText();
String text = "\"" + selection + "\"";
context.setText(text, text.getLength()); // here is the problem

Possible fix is to change assert in BaseKit:1286 to:

assert caretPosition >= 0 && (caretPosition <= insertionText.length() || (insertionText.isEmpty() && caretPosition == 0));

The difference is equals sign in: caretPosition <= insertionText.length()

Thanks.
Comment 1 Milutin Kristofic 2013-03-07 15:59:09 UTC
Thank you, you are right, I added special case with empty text, but it should be able with any length and any caret on the end of text.

http://hg.netbeans.org/jet-main/rev/e13d6a595745
Comment 2 Quality Engineering 2013-03-09 01:57:09 UTC
Integrated into 'main-golden', will be available in build *201303082300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e13d6a595745
User: Milutin Kristofic <mkristofic@netbeans.org>
Log: #227176 - Typinghooks API doesn't work properly