Loading ...
Sorry, an error occurred while loading the content.

68817Re: expand('%:h:h')

Expand Messages
  • Christian Brabandt
    Mar 23, 2013
    • 0 Attachment
      Hi Marcin!

      On Sa, 23 Mär 2013, Marcin Szamotulski wrote:

      > Dear Vim_Dev,
      >
      > If one is in the directory of the current file '%:h:h' expands to '.',
      > while it should expand tas '%:p:h:h' does. This is probably is not very
      > useful case since using '../' is much simpler, though it might be used
      > in a plugin (I've never been hit by this though). Expansion of '%:h:h'
      > works fine when the current directory is not where the current file is.
      >
      > Another, similar issue is when the current file is:
      > /home/user/directory/file.txt
      > and the current directory is
      > /home/user
      >
      > Then both '%:h:h' and '%:h:h:h' expand to '.'.

      I think this patch fixes it. It does so, by noticing, whether *fnamep
      has been set to '.' and if so and we are still trying to resolve one
      level up, will resolve '.' to an absolute path.

      diff --git a/src/eval.c b/src/eval.c
      --- a/src/eval.c
      +++ b/src/eval.c
      @@ -23902,6 +23902,17 @@
      {
      valid |= VALID_HEAD;
      *usedlen += 2;
      + if (*fnamep != NULL && **fnamep == '.' && *fnamelen == 1)
      + {
      + /* fnamep was already set to '.', try to move one directory up */
      + *fnamep = FullName_save(*fnamep, FALSE);
      + vim_free(*bufp);
      + if (*fnamep == NULL)
      + return -1;
      + p = *bufp = *fnamep;
      + tail = gettail(*fnamep);
      + *fnamelen = (int)STRLEN(*fnamep);
      + }
      s = get_past_head(*fnamep);
      while (tail > s && after_pathsep(s, tail))
      mb_ptr_back(*fnamep, tail);


      regards,
      Christian
      --
      Heute haben es die Frauen nur noch beim Friseur eilig, unter die Haube
      zu kommen.
      -- Joachim Fuchsberger

      --
      --
      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+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Show all 8 messages in this topic