Your intention is good to have this feature available in JavaScript file for comments and literal strings. But _isInCommentString() cannot verify that both selection start and selection end are in the same comment or in the same string. So it's possible to have a selection that spans across multiple comments or multiple strings.