patch 9.1.0759: screenpos() may return invalid position

Problem:  screenpos() may return invalid position
          after switching buffers (Greg Hurrell)
Solution: reset w_leftcol if wrapping has been set
          after copying wrap option

fixes: #15792
closes: #15803

Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_cursor_func.vim b/src/testdir/test_cursor_func.vim
index 2bdda86..8766f97 100644
--- a/src/testdir/test_cursor_func.vim
+++ b/src/testdir/test_cursor_func.vim
@@ -279,6 +279,21 @@
   bwipe!
 endfunc
 
+func Test_screenpos_edit_newfile()
+  new
+  20vsp
+  setl nowrap
+  call setline(1, 'abcdefghijklmnopqrstuvwxyz')
+  call cursor(1, 10)
+  norm! 5zl
+  call assert_equal(#{col: 5, row: 1, endcol: 5, curscol: 5}, screenpos(win_getid(), 1, 10))
+  enew!
+  call assert_equal(1, &l:wrap)
+  call assert_equal(#{col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1))
+
+  bwipe!
+endfunc
+
 " Save the visual start character position
 func SaveVisualStartCharPos()
   call add(g:VisualStartPos, getcharpos('v'))