*/
private int getOffset(IDocument document, StyledText textWidget, Point point)
throws BadLocationException {
int widgetCaret= fViewer.getTextWidget().getCaretOffset();
if (fViewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 ext= (ITextViewerExtension5) fViewer;
try {
return ext.widgetOffset2ModelOffset(textWidget.getOffsetAtLocation(point));
} catch (IllegalArgumentException e) {
int docLineIndex= ext.widgetLine2ModelLine(textWidget.getLineIndex(point.y));
String lineDelimiter= document.getLineDelimiter(docLineIndex);
int delimLength= lineDelimiter == null ? 0 : lineDelimiter.length();
return document.getLineOffset(docLineIndex) + document.getLineLength(docLineIndex)
- delimLength;
}