title: Get text in current line when some previous lines was collapsed in my own eclipse editor
body: <p>Im trying to get the text beginning of the current line to the mouse cursor.</p>
  
  <pre><code>ITextSelection textSelection= (ITextSelection) textEditor.getSelectionProvider().getSelection();
  IRegion lineInfo = null;
  int offsetCurrentCursor = textSelection.getOffset();
  int offsetLine; // THIS IS THE VALUE THAT I WANT
  try {
      int lineNumber = document.getLineOfOffset(offsetCurrentCursor);
      lineInfo = document.getLineInformation(lineNumber);
      offsetLine = lineInfo.getOffset();
  } catch (BadLocationException e) {
  }
  
  StyledText styledText = (StyledText) textEditor.getAdapter(Control.class);
  String currentText = "";
  if (offsetLine &lt;= offsetCurrentCursor - 1) {
      currentText = styledText.getText(offsetLine, offsetCurrentCursor - 1);
  }
  </code></pre>
  
  <p>But the method <code>getText</code> of <code>StyledText</code> doesn't work when some previous lines are collapsed.</p>
  
  <p>Another problem is that Im trying to move the cursor using <code>StyledText.setCaretOffset(int offset)</code> and it also doesn't work when some previous lines are collapsed.</p>