Fix #6441.

Add check for the line number to be positive.
Check for valid codeSnippet.
Do not set display line number for invalid lines
Merge pull request #6442 from busykai/fix-6441

Fix #6441.