Skip to content

Conversation

@lifecrisis
Copy link
Contributor

Closes: #12301

@zzzyxwvut
Copy link
Contributor

Depending on Col's provenance, tabs may be substituted for
runs of spaces, with or without its -h or -x flags.
The emulation comment should admit that there is no such
translation before or after :substitute.

Compare output:

{ man col | col -bx; } > /tmp/col.1.x
{ man col | col -bh; } > /tmp/col.1.h
{ man col | col -b; } > /tmp/col.1
diff -q /tmp/col.1.h /tmp/col.1
vimdiff -o /tmp/col.1.x /tmp/col.1

@lifecrisis
Copy link
Contributor Author

The emulation comment should admit that there is no such translation before or after :substitute.

I think referring to the issue is sufficient. There are other details left out of the comment that are equally relevant. Brevity requires that a number of details be omitted, which is why the link to the issue was added.

Personally, I would much rather remove any attempt to reformat the output of man at all since man makes use of col to reformat its text when output is not a terminal. All of this seems redundant now.

If man does the same thing on MacOS, I think we can get rid of it.

@codecov
Copy link

codecov bot commented Jun 18, 2023

Codecov Report

Merging #12557 (7fc6fd3) into master (bc385a1) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master   #12557      +/-   ##
==========================================
- Coverage   82.09%   82.08%   -0.01%     
==========================================
  Files         160      160              
  Lines      193650   193650              
  Branches    43481    43468      -13     
==========================================
- Hits       158978   158966      -12     
- Misses      21826    21840      +14     
+ Partials    12846    12844       -2     
Flag Coverage Δ
huge-clang-none 82.71% <ø> (-0.01%) ⬇️
linux 82.71% <ø> (-0.01%) ⬇️
mingw-x64-HUGE 76.60% <ø> (-0.01%) ⬇️
mingw-x86-HUGE 77.07% <ø> (-0.01%) ⬇️
windows 78.20% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 12 files with indirect coverage changes

@chrisbra
Copy link
Member

chrisbra commented Aug 9, 2023

should be okay to include. One question however:
@lifecrisis @goweol are you both co-maintaining the plugin?

@yegappan yegappan added this to the vim-9.1 milestone Aug 11, 2023
@chrisbra chrisbra merged commit 17befac into vim:master Aug 20, 2023
@chrisbra
Copy link
Member

thanks!

Konfekt pushed a commit to Konfekt/vim that referenced this pull request Aug 30, 2023
@ychin
Copy link
Contributor

ychin commented Sep 16, 2023

Hi, this change seems to have broken this plugin on Mac. This is the before:

Before

Now it looks like this (only when you invoke :Man ls from Vim, not when you are using it as a MANPAGER):

After

I haven't taken a closer look yet but can we revert the change while someone works on a fix?

Additionally, can we add some unit tests to prevent regressions in the future in the supported platforms? I think right now the bundled plugins are mostly untested which have from time to time result in regressions like this and basic regression tests on the main platforms would help catch the issues before they get merged (since from the looks of it this issue doesn't affect Linux and it's very easy for a contributor to forget testing on alternate platforms).

@ychin
Copy link
Contributor

ychin commented Sep 16, 2023

Actually, I found the issue. It's because I have set gdefault in my vimrc, and the substitute command uses the g flag, which gets inverted under this. Which to be fair, even if we have regression tests, this may not have been tested as it's an edge case.

I think we can fix it like so (I will open PR):

diff --git a/runtime/autoload/dist/man.vim b/runtime/autoload/dist/man.vim
index 315636a2ef..e517714f58 100644
--- a/runtime/autoload/dist/man.vim
+++ b/runtime/autoload/dist/man.vim
@@ -196,7 +196,11 @@ func dist#man#GetPage(cmdmods, ...)
 
   " Emulate piping the buffer through the "col -b" command.
   " Ref: https://github.com/vim/vim/issues/12301
-  silent! keepjumps keeppatterns %s/\v(.)\b\ze\1?//ge
+  if &gdefault
+    silent! keepjumps keeppatterns %s/\v(.)\b\ze\1?//e
+  else
+    silent! keepjumps keeppatterns %s/\v(.)\b\ze\1?//ge
+  endif
 
   if unsetwidth
     let $MANWIDTH = ''

The docs for gdefault does say that it's deprecated because of this reason, but I find it a little unsatisfactory:

				   *'gdefault'* *'gd'* *'nogdefault'* *'nogd'*
'gdefault' 'gd'		boolean	(default off)
			global
...
	DEPRECATED: Setting this option may break plugins that are not aware
	of this option.  Also, many users get confused that adding the /g flag
	has the opposite effect of that it normally does.
	This option is not used in |Vim9| script.

Feels to me we should just expose a way to do substitution that can ignore gdefault instead (like how ignorecase is ignored if \c or \C is used). Deprecating an option just because of plugins that don't account for them seem a little annoying, as I think the gdefault is actually a pretty useful option as most people expect it to be the case to begin with.

ychin added a commit to ychin/vim that referenced this pull request Sep 16, 2023
Fix the issue introduced by vim#12557. `:substitue` commands in plugins
need to take into account whether `gdefault` is set or not because
that depends on the user.
chrisbra pushed a commit that referenced this pull request Sep 16, 2023
Fix the issue introduced by #12557. `:substitute` commands in plugins
need to take into account whether `gdefault` is set or not because
that depends on the user.

closes: #13097

Signed-off-by: Christian Brabandt <[email protected]>
chrisbra pushed a commit to chrisbra/vim that referenced this pull request Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

:Man for any manpage opens an empty window

6 participants