Skip to content

Instantly share code, notes, and snippets.

@mattn
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/9388140 to your computer and use it in GitHub Desktop.
Save mattn/9388140 to your computer and use it in GitHub Desktop.
diff -r 10d35c8b50e3 src/window.c
--- a/src/window.c Mon Feb 24 03:32:00 2014 +0100
+++ b/src/window.c Mon Mar 10 10:11:15 2014 +0900
@@ -6093,6 +6093,9 @@
{
char_u *ptr;
int len;
+#ifdef _WIN32
+ int maybe_path = FALSE;
+#endif
/*
* search forward for what could be the start of a file name
@@ -6130,20 +6133,59 @@
* Also allow "://" when ':' is not in 'isfname'.
*/
len = 0;
+#ifdef _WIN32
+ /* Maybe it's a path. So if found ':' in next, it's an end of the
+ * path string. This should work as below:
+ *
+ * http://www.google.com/ => HTML content(OK)
+ * http:/asdf => E447 Can't find file "http:/asdf" (OK)
+ * http:/asdf/ => E447 Can't find file "http:/asdf/" (OK)
+ * file:c:/vim/src/ => E447: Can't find file "file:c:/vim/src/" in path
+ * file:/c:/vim/src/ => E447: Can't find file "file:/c:/vim/src/" in path
+ * file://c:/vim/src/ => Open the directory(OK)
+ * p:/asdf => E447 Can't find file "p:/asdf" (OK)
+ * p:/asdf/ => E447 Can't find file "p:/asdf/" (OK)
+ * _:/asdf/ => E447 Can't find file "_:/asdf/" (OK)
+ * _:asdf/ => E447 Can't find file "_:asdf/" (OK)
+ * :asdf/ => E447 Can't find file ":asdf/" (OK)
+ * c:/vim/src/gui_w48.c:1228: => Open the file(OK)
+ * c:/vim/src/gui_w48.c:1925: => Open the file(OK)
+ * ../../../vim/src/gui_w48.c:1925: => Open the file(OK)
+ * :::foo::: => E447 Can't find file ":::foo:::" (OK)
+ */
+ if (isalpha(ptr[0]) && ptr[1] == ':')
+ {
+ maybe_path = TRUE;
+ len = 2;
+ } else if (ptr[0] == '.')
+ maybe_path = TRUE;
+#endif
while (vim_isfilec(ptr[len])
|| ((options & FNAME_HYP) && path_is_url(ptr + len)))
+ {
+#ifdef _WIN32
+ if (maybe_path && ptr[len] == ':')
+ break;
+#endif
#ifdef FEAT_MBYTE
if (has_mbyte)
len += (*mb_ptr2len)(ptr + len);
else
#endif
++len;
+ }
/*
* If there is trailing punctuation, remove it.
* But don't remove "..", could be a directory name.
*/
- if (len > 2 && vim_strchr((char_u *)".,:;!", ptr[len - 1]) != NULL
+ if (
+#ifdef _WIN32
+ /* ":::foo:::" should be handled name of buffer as what we can see. */
+ maybe_path &&
+#endif
+ len > 2
+ && vim_strchr((char_u *)".,:;!", ptr[len - 1]) != NULL
&& ptr[len - 2] != '.')
--len;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment