Friday, March 22, 2013

TOhtml can't convert a diff of two unnamed buffers

On Thursday, March 21, 2013 3:10:14 PM UTC-5, Christian Brabandt wrote:
> Hi Ben!
>
> On Do, 21 M�r 2013, Ben Fritz wrote:
>
> > On Thursday, March 21, 2013 8:14:03 AM UTC-5, ping wrote:
> > > but looks I just find a new issue (maybe old/known?), this is reproducible:
> > >
> > > if the 2 buffer in vimdiff haven't been saved to files yet, the
> > > converted html output are the same one in the 2 panels -- they are just
> > > 2 copies of one of the files.
> > > but if I save the 2 buffers into files, then it's perfectly OK.
> > >
> >
> > Thanks, I've reproduced it. This is a bug unrelated to the original post,
> > please create a new thread if you find more.
> >
>
> I think, this patch fixes it:
>
> diff --git a/runtime/syntax/2html.vim b/runtime/syntax/2html.vim
> --- a/runtime/syntax/2html.vim
> +++ b/runtime/syntax/2html.vim
> @@ -607,7 +607,7 @@
> let s:orgbufnr = winbufnr(0)
> let s:origwin_stl = &l:stl
> if expand("%") == ""
> - exec 'new Untitled.'.(s:settings.use_xhtml ? 'x' : '').'html'
> + exec 'new +enew Untitled.'.(s:settings.use_xhtml ? 'x' : '').'html'
> else
> exec 'new %.'.(s:settings.use_xhtml ? 'x' : '').'html'
> endif
>

Thanks, Christian! This should fix it for diff mode, but for single file
conversions now the converted buffer will not have a name. We need to find a
unique buffer name instead of always using "Untitled.html", at least during
converting files in diff mode.

Now that you found the problem, I think the better solution would be to add a
number or something to the buffer name when converting untitled buffers. Since
the problem only occurs in diff mode I think we could make use of
g:html_diff_win_num to make sure it is unique across diff buffers without
requiring complicated logic to find an unused buffer name.

If somebody wants to come up with something to find an unused buffer name,
that's fine too. That would fix that if you happen to be editing a file called
Untitled.html in the current directory already, :TOhtml on an unnamed buffer
will wipe out the existing buffer. But I don't think this is common enough to
spend a lot of effort on a fix.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: