Look for the first non empty line preceeding the current line, or if not found, the first non empty line following it. Fixes #1904