Here is the latest patch attached where i fixed those segfaults: this was
really stupid to me to change first character in a static buffer, i just
did not know how b_p_bh was using memory.
Syntax also works fine. Except.... You won't believe!
I said that i used plugin dbext. It has autogroup commands:
augroup dbext
au!
autocmd BufEnter * if exists('g:loaded_dbext_auto') != 0 | exec
"call dbext#DB_setTitle()" | endif
autocmd BufReadPost * if &modeline == 1 | call dbext#DB_checkModeline()
| endif
autocmd BufDelete * if exists('g:loaded_dbext_auto') != 0 | exec
'call dbext#DB_auBufDelete( expand("<abuf>") )' | endif
autocmd VimLeavePre * if exists('g:loaded_dbext_auto') != 0 | exec
'call dbext#DB_auVimLeavePre()' | endif
augroup END
Syntax highlight when switching back from last window in tabpage won't work
in this original state. It will work if i remove autocmd BufReadPost. I
made some investigations and found that if i use modeline == 0, in which
case function dbext#DB_checkModeline() won't be called syntax hl won't work
either. Of course i thought that there was something in the vim code that
prevented normal work of the syntax when any BufReadPost autocmd had been
just declared. But occasionally i found that something like
autocmd BufReadPost * if &modeline == 1 | echo "AAA" | endif
worked perfectly (e.g. highlighted reverted buffer). Eventually i found
that symbol '#' in
autocmd BufReadPost * if &modeline == 1 | call dbext#DB_checkModeline()
| endif
prevents normal loading of the syntax. This is extremely weird. And i even
do not want to search what could be the cause of the issue. But of course
this smells like a bug.
In my dbext plugin i fixed this by simply moving dbext#DB_checkModeline()
from autoload to plugin/dbext.vim and renaming it to DB_checkModeline().
Now the autocmd is
autocmd BufReadPost * if &modeline == 1 | call DB_checkModeline() |
endif
and all works perfectly, i.e. syntax highlighting is OK and buffer is not
unloaded. Also i checked that folds are kept and all the same for quitting
from quickfix window.
Cheers, Alexey.
2011/11/15 Alexey Radkov <[email protected]>
> Thank you all, guys, for response.
>
> Actually the patch i attached is not perfect: it may lead to segfaults if
> bufhidden is empty. Currently i am working on another patch which fixes the
> issue, and i am struggling with syntax issue which is not working if dbext
> plugin is used because dbext uses additional BufReadPost autocmd which
> somehow prevents syntax in buffer where we return from highlighting. If i
> remove this single autocmd then syntax works fine. Surprisingly it does not
> matter which content of this autocmd is, it only matters the fact of
> presence of autocmd itself. Looks weird.
>
>
> 2011/11/15 Thilo Six <[email protected]>
>
>> Alexey Radkov wrote the following on 14.11.2011 20:41
>>
>> Hello Alexey,
>>
>> -- <snip> --
>> > You will be returned to the original file, but... Now there is no
>> > syntax highlight and ':ls' will show that there is no current buffer!
>> > ':ls!' will show that the current buffer is unloaded. Same behaviour
>> > can be found when using quickfix window instead tabpage.
>> -- <snip> --
>>
>>
>> Thank you for the detailed analysis and the patch. I assume that your
>> foundings
>> are also related to an issue that i had myself recently without being
>> able to
>> come to any useful solution.
>> http://thread.gmane.org/gmane.editors.vim
>> /100772<http://thread.gmane.org/gmane.editors.vim/100772>
>>
>> --
>> Regards,
>> Thilo
>>
>> 4096R/0xC70B1A8F
>> 721B 1BA0 095C 1ABA 3FC6 7C18 89A4 A2A0 C70B 1A8F
>>
>>
>> --
>> 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 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
diff -r 379a6398d462 src/buffer.c
--- a/src/buffer.c Wed Oct 26 23:48:21 2011 +0200
+++ b/src/buffer.c Tue Nov 15 23:10:49 2011 +0300
@@ -1370,12 +1370,21 @@
if (buf_valid(prevbuf))
#endif
{
+ u_char *saveopt;
+
if (prevbuf == curbuf)
u_sync(FALSE);
+ if (action == DOBUF_GOTO)
+ {
+ saveopt = prevbuf->b_p_bh;
+ prevbuf->b_p_bh = empty_option;
+ }
close_buffer(prevbuf == curwin->w_buffer ? curwin : NULL, prevbuf,
unload ? action : (action == DOBUF_GOTO
&& !P_HID(prevbuf)
&& !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0);
+ if (action == DOBUF_GOTO && buf_valid(prevbuf))
+ prevbuf->b_p_bh = saveopt;
}
}
#ifdef FEAT_AUTOCMD
diff -r 379a6398d462 src/window.c
--- a/src/window.c Wed Oct 26 23:48:21 2011 +0200
+++ b/src/window.c Tue Nov 15 23:10:49 2011 +0300
@@ -2309,7 +2309,7 @@
/*
* Close window "win" in tab page "tp", which is not the current tab page.
- * This may be the last window ih that tab page and result in closing the tab,
+ * This may be the last window in that tab page and result in closing the tab,
* thus "tp" may become invalid!
* Caller must check if buffer is hidden and whether the tabline needs to be
* updated.