Re: [vim/vim] netrw: Unexpected behaviour when g:netrw_altfile is set to 1 (#1246)

2016-11-22 Fir de Conversatie Charles E Campbell
Martin Vuille wrote:
>
> @cecamp  Any thoughts on this issue?
> I'm willing to try to diagnose it further, just need some general guidance
>
>
Hello:

My home computer is having problems, so I'm trying to get it working
properly again.

Presumably something needs a "keepalt" that currently doesn't have it. 
Tracking that sort of thing down can be tedious.  I'm hoping to try
Christian Brabandt's "breakpoint expr" patch; it doesn't appear to have
made it in vim v8 and use it to track down where @# changes.

Regards,
Chip Campbell

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[patch][Win32] Fix CenterWindow() function on multiple monitors

2016-11-22 Fir de Conversatie Ken Takata
Hi,

The CenterWindow() function in gui_w32.c doesn't work properly on multiple
monitors.  E.g.:

1. Open a gvim window on the secondary monitor.
2. Input some texts. (e.g. iHello)
3. Press Alt+F4 to close the window.
4. A message box (Save changes to "Untitled"?) will be shown on the primary
   monitor.  It should be shown on the secondary monitor.

Attached patch fixes the problem.
Also attached a patch for fixing some coding style and indentation problems.

Regards,
Ken Takata

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# HG changeset patch
# Parent  8ecfeee190111016916fb85ae8a0aefed8c75cee

diff --git a/src/gui_w32.c b/src/gui_w32.c
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -2298,19 +2298,24 @@ GetTextWidthEnc(HDC hdc, char_u *str, in
 # define GetTextWidthEnc(h, s, l) GetTextWidth((h), (s), (l))
 #endif
 
+static void get_work_area(RECT *spi_rect);
+
 /*
  * A quick little routine that will center one window over another, handy for
- * dialog boxes.  Taken from the Win32SDK samples.
+ * dialog boxes.  Taken from the Win32SDK samples and modified for multiple
+ * monitors.
  */
 static BOOL
 CenterWindow(
 HWND hwndChild,
 HWND hwndParent)
 {
-RECTrChild, rParent;
-int wChild, hChild, wParent, hParent;
-int wScreen, hScreen, xNew, yNew;
-HDC hdc;
+HMONITOR	mon;
+MONITORINFO	moninfo;
+RECT	rChild, rParent, rScreen;
+int 	wChild, hChild, wParent, hParent;
+int 	xNew, yNew;
+HDC 	hdc;
 
 GetWindowRect(hwndChild, );
 wChild = rChild.right - rChild.left;
@@ -2318,32 +2323,39 @@ CenterWindow(
 
 /* If Vim is minimized put the window in the middle of the screen. */
 if (hwndParent == NULL || IsMinimized(hwndParent))
-	SystemParametersInfo(SPI_GETWORKAREA, 0, , 0);
+	get_work_area();
 else
 	GetWindowRect(hwndParent, );
 wParent = rParent.right - rParent.left;
 hParent = rParent.bottom - rParent.top;
 
-hdc = GetDC(hwndChild);
-wScreen = GetDeviceCaps (hdc, HORZRES);
-hScreen = GetDeviceCaps (hdc, VERTRES);
-ReleaseDC(hwndChild, hdc);
-
-xNew = rParent.left + ((wParent - wChild) /2);
-if (xNew < 0)
-{
-	xNew = 0;
-}
-else if ((xNew+wChild) > wScreen)
-{
-	xNew = wScreen - wChild;
-}
-
-yNew = rParent.top	+ ((hParent - hChild) /2);
-if (yNew < 0)
-	yNew = 0;
-else if ((yNew+hChild) > hScreen)
-	yNew = hScreen - hChild;
+moninfo.cbSize = sizeof(MONITORINFO);
+mon = MonitorFromWindow(hwndChild, MONITOR_DEFAULTTOPRIMARY);
+if (mon != NULL && GetMonitorInfo(mon, ))
+{
+	rScreen = moninfo.rcWork;
+}
+else
+{
+	hdc = GetDC(hwndChild);
+	rScreen.left = 0;
+	rScreen.top = 0;
+	rScreen.right = GetDeviceCaps(hdc, HORZRES);
+	rScreen.bottom = GetDeviceCaps(hdc, VERTRES);
+	ReleaseDC(hwndChild, hdc);
+}
+
+xNew = rParent.left + ((wParent - wChild) / 2);
+if (xNew < rScreen.left)
+	xNew = rScreen.left;
+else if ((xNew + wChild) > rScreen.right)
+	xNew = rScreen.right - wChild;
+
+yNew = rParent.top + ((hParent - hChild) / 2);
+if (yNew < rScreen.top)
+	yNew = rScreen.top;
+else if ((yNew + hChild) > rScreen.bottom)
+	yNew = rScreen.bottom - hChild;
 
 return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0,
 		   SWP_NOSIZE | SWP_NOZORDER);
@@ -5560,7 +5572,7 @@ get_work_area(RECT *spi_rect)
 MONITORINFO	moninfo;
 
 /* work out which monitor the window is on, and get *it's* work area */
-mon = MonitorFromWindow(s_hwnd, 1 /*MONITOR_DEFAULTTOPRIMARY*/);
+mon = MonitorFromWindow(s_hwnd, MONITOR_DEFAULTTOPRIMARY);
 if (mon != NULL)
 {
 	moninfo.cbSize = sizeof(MONITORINFO);
# HG changeset patch
# Parent  276c79c8ae0062ebc0809245b21a520662f7d608

diff --git a/src/gui_w32.c b/src/gui_w32.c
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -3540,12 +3540,12 @@ gui_mch_browseW(
 filterp = convert_filterW(filter);
 
 vim_memset(, 0, sizeof(OPENFILENAMEW));
-#ifdef OPENFILENAME_SIZE_VERSION_400W
+#  ifdef OPENFILENAME_SIZE_VERSION_400W
 /* be compatible with Windows NT 4.0 */
 fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400W;
-#else
+#  else
 fileStruct.lStructSize = sizeof(fileStruct);
-#endif
+#  endif
 
 if (title != NULL)
 	titlep = enc_to_utf16(title, NULL);
@@ -3582,10 +3582,10 @@ gui_mch_browseW(
  * Don't use OFN_OVERWRITEPROMPT, Vim has its own ":confirm" dialog.
  */
 fileStruct.Flags = (OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY);
-#ifdef FEAT_SHORTCUT
+#  ifdef FEAT_SHORTCUT
 

[patch] `:tab drop xx` does not jump to existing xx window

2016-11-22 Fir de Conversatie h_east
Hi Bram and list,

How to reproduce:
- Start Vanilla Vim edit xx
  $ vim -Nu NONE xx
- Split verticaly and create window for empty buffer.
  :vnew
- Jump to a such window or create new tabpage. Actually, already xx exists, it 
jumps to that window.
  :tab drop xx

Expected behavior:
- Jumps to xx window. because xx already exists.

Actual behavior:
- Create a new tabpage unexpectedly.

NOTE:
When `:new` is used instead of `:vnew`, it will be the expected behavior.

Investigation result:
do_arg_all()'s 3rd argument `keep_tabs` is false that means for mainly `:all` 
command.
And...
[src/buffer.c]
4860 if (buf->b_ffname == NULL
4861 || (!keep_tabs && (buf->b_nwindows > 1
4862 || wp->w_width != Columns)))

Also `wp->w_width != Columns` should for only `!keep_tabs` (:all command).

I wrote a patch contained a test.
Check and include it please.

BTW, the following description(at L4846) does not seem to be written in the 
document of `:all`.
[src/buffer.c]
4844 /*
4845  * Try closing all windows that are not in the argument list.
4846  * Also close windows that are not full width;

Add to a document? or remove a code?

--
Best regards,
Hirohito Higashi (a.k.a. h_east)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/buffer.c b/src/buffer.c
index e5d2dde..e77fc04 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -4858,8 +4858,8 @@ do_arg_all(
 	wpnext = wp->w_next;
 	buf = wp->w_buffer;
 	if (buf->b_ffname == NULL
-		|| (!keep_tabs && buf->b_nwindows > 1)
-		|| wp->w_width != Columns)
+		|| (!keep_tabs && (buf->b_nwindows > 1
+			|| wp->w_width != Columns)))
 		i = opened_len;
 	else
 	{
diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim
index 3f69fb9..1720107 100644
--- a/src/testdir/test_tabpage.vim
+++ b/src/testdir/test_tabpage.vim
@@ -65,6 +65,15 @@ function Test_tabpage()
 call assert_true(tabpagenr() == 2 && tabpagewinnr(2, '$') == 2 && tabpagewinnr(2) == 1)
 tabclose
 q
+"
+"
+" Test for ":tab drop vertical-split-window" to jump test1 buffer
+tabedit test1
+vnew
+tabfirst
+tab drop test1
+call assert_equal([2, 2, 2, 2], [tabpagenr('$'), tabpagenr(), tabpagewinnr(2, '$'), tabpagewinnr(2)])
+1tabonly
   endif
   "
   "