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:
http://grepcode.com/file/repository.grepcode.com/java/ext/com.jetbrains/intellij-idea/10.0/com/intellij/openapi/editor/Document.java
Returns the line number (0-based) corresponding to the specified offset in the document.
- Parameters:
-
offset
the offset to get the line number for (must be in the range from 0 to getTextLength()-1) - Returns:
- the line number corresponding to the offset.
int getLineNumber(int offset);
my question is:
since 100 == aDoc.getLineNumber(100), why i need getLineNumber(int).
Please sign in to leave a comment.
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.