@@ -78,6 +78,7 @@ get_pos_options(win_T *wp, dict_T *dict)
7878{
7979 char_u * str ;
8080 int nr ;
81+ dictitem_T * di ;
8182
8283 nr = popup_options_one (dict , (char_u * )"line" );
8384 if (nr > 0 )
@@ -86,7 +87,9 @@ get_pos_options(win_T *wp, dict_T *dict)
8687 if (nr > 0 )
8788 wp -> w_wantcol = nr ;
8889
89- wp -> w_popup_fixed = dict_get_number (dict , (char_u * )"fixed" ) != 0 ;
90+ di = dict_find (dict , (char_u * )"fixed" , -1 );
91+ if (di != NULL )
92+ wp -> w_popup_fixed = dict_get_number (dict , (char_u * )"fixed" ) != 0 ;
9093
9194 str = dict_get_string (dict , (char_u * )"pos" , FALSE);
9295 if (str != NULL )
@@ -666,10 +669,12 @@ popup_adjust_position(win_T *wp)
666669 int org_wincol = wp -> w_wincol ;
667670 int org_width = wp -> w_width ;
668671 int org_height = wp -> w_height ;
672+ int org_leftcol = wp -> w_leftcol ;
669673 int minwidth ;
670674
671675 wp -> w_winrow = 0 ;
672676 wp -> w_wincol = 0 ;
677+ wp -> w_leftcol = 0 ;
673678 if (wp -> w_popup_pos == POPPOS_CENTER )
674679 {
675680 // center after computing the size
@@ -785,10 +790,21 @@ popup_adjust_position(win_T *wp)
785790 else if (wp -> w_popup_pos == POPPOS_BOTRIGHT
786791 || wp -> w_popup_pos == POPPOS_TOPRIGHT )
787792 {
793+ int leftoff = wp -> w_wantcol - (wp -> w_width + extra_width );
794+
788795 // Right aligned: move to the right if needed.
789796 // No truncation, because that would change the height.
790- if (wp -> w_width + extra_width < wp -> w_wantcol )
791- wp -> w_wincol = wp -> w_wantcol - (wp -> w_width + extra_width );
797+ if (leftoff >= 0 )
798+ wp -> w_wincol = leftoff ;
799+ else if (wp -> w_popup_fixed )
800+ {
801+ // "col" specifies the right edge, but popup doesn't fit, skip some
802+ // columns when displaying the window.
803+ wp -> w_leftcol = - leftoff ;
804+ wp -> w_width += leftoff ;
805+ if (wp -> w_width < 0 )
806+ wp -> w_width = 0 ;
807+ }
792808 }
793809
794810 wp -> w_height = wp -> w_buffer -> b_ml .ml_line_count - wp -> w_topline
@@ -823,6 +839,7 @@ popup_adjust_position(win_T *wp)
823839 // And redraw windows that were behind the popup.
824840 if (org_winrow != wp -> w_winrow
825841 || org_wincol != wp -> w_wincol
842+ || org_leftcol != wp -> w_leftcol
826843 || org_width != wp -> w_width
827844 || org_height != wp -> w_height )
828845 {
@@ -1078,6 +1095,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
10781095 for (i = 0 ; i < 8 ; ++ i )
10791096 wp -> w_border_char [i ] = 0 ;
10801097 wp -> w_want_scrollbar = 1 ;
1098+ wp -> w_popup_fixed = 0 ;
10811099
10821100 // Deal with options.
10831101 apply_options (wp , argvars [1 ].vval .v_dict );
@@ -1909,7 +1927,7 @@ popup_check_cursor_pos()
19091927 static int
19101928popup_masked (win_T * wp , int screencol , int screenline )
19111929{
1912- int col = screencol - wp -> w_wincol + 1 ;
1930+ int col = screencol - wp -> w_wincol + 1 + wp -> w_leftcol ;
19131931 int line = screenline - wp -> w_winrow + 1 ;
19141932 listitem_T * lio , * li ;
19151933 int width , height ;
@@ -1988,7 +2006,13 @@ update_popup_transparent(win_T *wp, int val)
19882006 linee = height + linee + 1 ;
19892007
19902008 -- cols ;
2009+ cols -= wp -> w_leftcol ;
2010+ if (cols < 0 )
2011+ cols = 0 ;
2012+ cole -= wp -> w_leftcol ;
19912013 -- lines ;
2014+ if (lines < 0 )
2015+ lines = 0 ;
19922016 for (line = lines ; line < linee && line < screen_Rows ; ++ line )
19932017 for (col = cols ; col < cole && col < screen_Columns ; ++ col )
19942018 popup_transparent [(line + wp -> w_winrow ) * screen_Columns
0 commit comments