mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	vim-patch:9.0.1072: screenpos() column result in fold may be too small (#21465)
Problem:    screenpos() column result in fold may be too small.
Solution:   Add space of 'number', sign column, etc. (closes vim/vim#11715)
ba2d191932
			
			
This commit is contained in:
		| @@ -937,21 +937,18 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp, | ||||
|   bool existing_row = (pos->lnum > 0 | ||||
|                        && pos->lnum <= wp->w_buffer->b_ml.ml_line_count); | ||||
|  | ||||
|   if ((local || visible_row) && existing_row) { | ||||
|     const colnr_T off = win_col_off(wp); | ||||
|     if (is_folded) { | ||||
|       row += local ? 0 : wp->w_winrow + wp->w_winrow_off; | ||||
|     coloff = (local ? 0 : wp->w_wincol + wp->w_wincol_off) + 1; | ||||
|   } else if ((local || visible_row) && existing_row) { | ||||
|     colnr_T off; | ||||
|     colnr_T col; | ||||
|     int width; | ||||
|  | ||||
|       coloff = (local ? 0 : wp->w_wincol + wp->w_wincol_off) + 1 + off; | ||||
|     } else { | ||||
|       getvcol(wp, pos, &scol, &ccol, &ecol); | ||||
|  | ||||
|       // similar to what is done in validate_cursor_col() | ||||
|     col = scol; | ||||
|     off = win_col_off(wp); | ||||
|       colnr_T col = scol; | ||||
|       col += off; | ||||
|     width = wp->w_width - off + win_col_off2(wp); | ||||
|       int width = wp->w_width - off + win_col_off2(wp); | ||||
|  | ||||
|       // long line wrapping, adjust row | ||||
|       if (wp->w_p_wrap && col >= (colnr_T)wp->w_width && width > 0) { | ||||
| @@ -975,6 +972,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp, | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   *rowp = row + rowoff; | ||||
|   *scolp = scol + coloff; | ||||
|   *ccolp = ccol + coloff; | ||||
|   | ||||
| @@ -138,8 +138,12 @@ func Test_screenpos_fold() | ||||
|   redraw | ||||
|   call assert_equal(2, screenpos(1, 2, 1).row) | ||||
|   call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 3, 1)) | ||||
|   call assert_equal(3, screenpos(1, 4, 1).row) | ||||
|   call assert_equal(3, screenpos(1, 5, 1).row) | ||||
|   call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 4, 1)) | ||||
|   call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 5, 1)) | ||||
|   setlocal number | ||||
|   call assert_equal(#{col: 5, row: 3, endcol: 5, curscol: 5}, screenpos(1, 3, 1)) | ||||
|   call assert_equal(#{col: 5, row: 3, endcol: 5, curscol: 5}, screenpos(1, 4, 1)) | ||||
|   call assert_equal(#{col: 5, row: 3, endcol: 5, curscol: 5}, screenpos(1, 5, 1)) | ||||
|   call assert_equal(4, screenpos(1, 6, 1).row) | ||||
|   bwipe! | ||||
| endfunc | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 zeertzjq
					zeertzjq