Why i need "getLineNumber(int offset)"

i see idea source from http://grepcode.com/file/repository.grepcode.com/java/ext/com.jetbrains/intellij-idea/10.0/com/intellij/openapi/editor/Document.java

the doc of getLineNumber is:


Returns the line number (0-based) corresponding to the specified offset in the document.

the offset to get the line number for (must be in the range from 0 to getTextLength()-1)
the line number corresponding to the offset.
 int getLineNumber(int offset);

my question is:
since 100 == aDoc.getLineNumber(100), why i need getLineNumber(int).

1 comment
Comment actions Permalink

The offset is measured in characters, not lines. The only case where getLineNumber(100) would be 100 is a file consisting entirely of linebreak characters.


Please sign in to leave a comment.