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

[patch] diffoff! does not check &diff in current window

Expand Messages
  • Charles Cooper
    The diffoff! and diffoff commands both reset options in the window they are called from without checking the value of &diff. The options which the commands
    Message 1 of 4 , Sep 18, 2013
    • 0 Attachment
      The diffoff! and diffoff commands both reset options in the window they are called from without checking the value of &diff. The options which the commands reset are: diff, scrollbind, cursorbind, scrollopt, wrap, foldmethod, foldcolumn. Here are 2 examples using the wrap option, after starting with
      vim -n -u NONE -U NONE -i NONE --noplugin

      set nowrap
      set wrap ? | echon " " bufnr("%")
      diffoff
      set wrap ? | echon " " bufnr("%")

      set nowrap
      silent edit a | silent diffsplit b | silent split c
      set wrap ? | echon " " bufnr("%")
      diffoff!
      set wrap ? | echon " " bufnr("%")


      patch inline and attached


      *** old/diff.c Thu Jul 18 12:11:03 2013
      --- new/diff.c Wed Sep 18 12:10:14 2013
      ***************
      *** 1203,1209 ****

      for (wp = firstwin; wp != NULL; wp = wp->w_next)
      {
      ! if (wp == curwin || (eap->forceit && wp->w_p_diff))
      {
      /* Set 'diff', 'scrollbind' off and 'wrap' on. If option values
      * were saved in diff_win_options() restore them. */
      --- 1203,1209 ----

      for (wp = firstwin; wp != NULL; wp = wp->w_next)
      {
      ! if ((wp == curwin || eap->forceit) && wp->w_p_diff)
      {
      /* Set 'diff', 'scrollbind' off and 'wrap' on. If option values
      * were saved in diff_win_options() restore them. */

      --
      --
      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.
    • Bram Moolenaar
      ... I would say the current behavior is intended. If you reset diff , but then realize it doesn t look right, you can use :diffoff to reset the other side
      Message 2 of 4 , Sep 19, 2013
      • 0 Attachment
        Charles Cooper wrote:

        > The diffoff! and diffoff commands both reset options in the window
        > they are called from without checking the value of &diff. The options
        > which the commands reset are: diff, scrollbind, cursorbind, scrollopt,
        > wrap, foldmethod, foldcolumn. Here are 2 examples using the wrap
        > option, after starting with
        > vim -n -u NONE -U NONE -i NONE --noplugin
        >
        > set nowrap
        > set wrap ? | echon " " bufnr("%")
        > diffoff
        > set wrap ? | echon " " bufnr("%")
        >
        > set nowrap
        > silent edit a | silent diffsplit b | silent split c
        > set wrap ? | echon " " bufnr("%")
        > diffoff!
        > set wrap ? | echon " " bufnr("%")
        >
        >
        > patch inline and attached

        I would say the current behavior is intended. If you reset 'diff', but
        then realize it doesn't look right, you can use :diffoff to reset the
        other side effects of :diffthis.

        If you don't want to change options, then why would you type :diffoff?

        --
        "The amigos also appear to be guilty of not citing the work of others who had
        gone before them. Even worse, they have a chapter about modeling time and
        space without making a single reference to Star Trek!"
        (Scott Ambler, reviewing the UML User Guide)

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        --
        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.
      • Charles Cooper
        ... I never thought of that! ... For me, this appeared using diffoff! with a 3 window split: 2 windows in a diff and 1 window not in the diff with related
        Message 3 of 4 , Sep 19, 2013
        • 0 Attachment
          On Thursday, September 19, 2013 3:45:24 PM UTC-4, Bram Moolenaar wrote:

          > I would say the current behavior is intended. If you reset 'diff', but
          > then realize it doesn't look right, you can use :diffoff to reset the
          > other side effects of :diffthis.

          I never thought of that!

          > If you don't want to change options, then why would you type :diffoff?

          For me, this appeared using diffoff! with a 3 window split: 2 windows in a diff and 1 window not in the diff with related information.

          When issuing diffoff! from the non-diff window, the 2 diff windows have their options reset as documented. The non-diff window also has its options reset, which I did not expect. The options in that non-diff window will always be set to vim defaults because options are only saved for windows which are part of a diff.

          This situation does not occur often and can be worked around.



          --
          --
          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.
        • Bram Moolenaar
          ... OK, if you use diffoff! one would expect it to only apply to windows with diff set. So the condition should be: if (eap- forceit ? wp- w_p_diff : wp ==
          Message 4 of 4 , Sep 20, 2013
          • 0 Attachment
            Charles Cooper wrote:

            > On Thursday, September 19, 2013 3:45:24 PM UTC-4, Bram Moolenaar wrote:
            >
            > > I would say the current behavior is intended. If you reset 'diff', but
            > > then realize it doesn't look right, you can use :diffoff to reset the
            > > other side effects of :diffthis.
            >
            > I never thought of that!
            >
            > > If you don't want to change options, then why would you type :diffoff?
            >
            > For me, this appeared using diffoff! with a 3 window split: 2 windows
            > in a diff and 1 window not in the diff with related information.
            >
            > When issuing diffoff! from the non-diff window, the 2 diff windows
            > have their options reset as documented. The non-diff window also has
            > its options reset, which I did not expect. The options in that
            > non-diff window will always be set to vim defaults because options are
            > only saved for windows which are part of a diff.
            >
            > This situation does not occur often and can be worked around.

            OK, if you use diffoff! one would expect it to only apply to windows
            with 'diff' set. So the condition should be:

            if (eap->forceit ? wp->w_p_diff : wp == curwin)

            And make this clear in the documentation:

            :diffo[ff]! Switch off diff mode for the current window and in all windows
            in the current tab page where 'diff' is set. Resetting
            related options only happens in a window that has 'diff' set,
            if the current window does not have 'diff' set then no options
            in it are changed.
            --
            "Women marry men hoping they will change. Men marry women hoping
            they will not. So each is inevitably disappointed."
            - Einstein

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
            \\\ an exciting new programming language -- http://www.Zimbu.org ///
            \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

            --
            --
            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.
          Your message has been successfully submitted and would be delivered to recipients shortly.