Skip to content

Commit 6bc9305

Browse files
committed
patch 8.1.1127: getwinpos() doesn't work in terminal on MS-Windows console
Problem: getwinpos() doesn't work in terminal on MS-Windows console. Solution: Adjust #ifdefs. Disable test for MS-Windows console.
1 parent 3d3f217 commit 6bc9305

5 files changed

Lines changed: 22 additions & 11 deletions

File tree

src/term.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,7 +2843,7 @@ static int winpos_x = -1;
28432843
static int winpos_y = -1;
28442844
static int did_request_winpos = 0;
28452845

2846-
# if (defined(FEAT_EVAL) && defined(HAVE_TGETENT)) || defined(PROTO)
2846+
# if defined(FEAT_EVAL) || defined(FEAT_TERMINAL) || defined(PROTO)
28472847
/*
28482848
* Try getting the Vim window position from the terminal.
28492849
* Returns OK or FAIL.
@@ -4858,7 +4858,7 @@ check_termcode(
48584858

48594859
/*
48604860
* Check for a window position response from the terminal:
4861-
* {lead}3;{x}:{y}t
4861+
* {lead}3;{x};{y}t
48624862
*/
48634863
else if (did_request_winpos
48644864
&& ((len >= 4 && tp[0] == ESC && tp[1] == '[')
@@ -4925,23 +4925,23 @@ check_termcode(
49254925
if (i - j >= 21 && STRNCMP(tp + j + 3, "rgb:", 4) == 0
49264926
&& tp[j + 11] == '/' && tp[j + 16] == '/')
49274927
{
4928-
#ifdef FEAT_TERMINAL
4928+
# ifdef FEAT_TERMINAL
49294929
int rval = hexhex2nr(tp + j + 7);
49304930
int gval = hexhex2nr(tp + j + 12);
49314931
int bval = hexhex2nr(tp + j + 17);
4932-
#endif
4932+
# endif
49334933
if (is_bg)
49344934
{
49354935
char *newval = (3 * '6' < tp[j+7] + tp[j+12]
49364936
+ tp[j+17]) ? "light" : "dark";
49374937

49384938
LOG_TR(("Received RBG response: %s", tp));
49394939
rbg_status = STATUS_GOT;
4940-
#ifdef FEAT_TERMINAL
4940+
# ifdef FEAT_TERMINAL
49414941
bg_r = rval;
49424942
bg_g = gval;
49434943
bg_b = bval;
4944-
#endif
4944+
# endif
49454945
if (!option_was_set((char_u *)"bg")
49464946
&& STRCMP(p_bg, newval) != 0)
49474947
{
@@ -4952,7 +4952,7 @@ check_termcode(
49524952
redraw_asap(CLEAR);
49534953
}
49544954
}
4955-
#ifdef FEAT_TERMINAL
4955+
# ifdef FEAT_TERMINAL
49564956
else
49574957
{
49584958
LOG_TR(("Received RFG response: %s", tp));
@@ -4961,7 +4961,7 @@ check_termcode(
49614961
fg_g = gval;
49624962
fg_b = bval;
49634963
}
4964-
#endif
4964+
# endif
49654965
}
49664966

49674967
/* got finished code: consume it */

src/terminal.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3866,8 +3866,11 @@ parse_csi(
38663866
if (command != 't' || argcount != 1 || args[0] != 13)
38673867
return 0; // not handled
38683868

3869-
// When getting the window position fails it results in zero/zero.
3869+
// When getting the window position is not possible or it fails it results
3870+
// in zero/zero.
3871+
#if defined(FEAT_GUI) || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE))
38703872
(void)ui_get_winpos(&x, &y, (varnumber_T)100);
3873+
#endif
38713874

38723875
FOR_ALL_WINDOWS(wp)
38733876
if (wp->w_buffer == term->tl_buffer)

src/testdir/test_terminal.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,11 @@ func Test_terminal_statusline()
18891889
endfunc
18901890

18911891
func Test_terminal_getwinpos()
1892+
" does not work in the MS-Windows console
1893+
if has('win32') && !has('gui')
1894+
return
1895+
endif
1896+
18921897
" split, go to the bottom-right window
18931898
split
18941899
wincmd j

src/ui.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,10 +627,9 @@ ui_new_shellsize(void)
627627
}
628628
}
629629

630-
#if (defined(FEAT_EVAL) \
630+
#if ((defined(FEAT_EVAL) || defined(FEAT_TERMINAL)) \
631631
&& (defined(FEAT_GUI) \
632632
|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)))) \
633-
|| defined(FEAT_TERMINAL) \
634633
|| defined(PROTO)
635634
/*
636635
* Get the window position in pixels, if possible.
@@ -645,6 +644,8 @@ ui_get_winpos(int *x, int *y, varnumber_T timeout)
645644
# endif
646645
# if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
647646
return term_get_winpos(x, y, timeout);
647+
# else
648+
return FAIL;
648649
# endif
649650
}
650651
#endif

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1127,
774776
/**/
775777
1126,
776778
/**/

0 commit comments

Comments
 (0)