Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: mg: prevet crash with invalid compile buffer
To:
Dante Catalfamo <dante@lambda.cx>
Cc:
tech@openbsd.org
Date:
Fri, 02 Aug 2024 00:09:54 +0200

Download raw body.

Thread
On 2024/08/01 15:19:23 -0400, "Dante Catalfamo" <dante@lambda.cx> wrote:
> Found the issuse. If the window is already displaying but not focused,
> we return true instead of making it the current window, so when
> next-error checks if we're at the bottom of the buffer, it's looking at
> whatever we're focused on. 

oh right, good catch!  I forgot to test that case.

more below.

> [...]
> +static int
> +show_compile_buffer(void)
> +{
> +	struct mgwin	*wp;
> +	struct buffer	*bp;
> +
> +	if (checkbuffermode(curbp, "compile") == TRUE) {
> +		return (TRUE);
> +	}
> +
> +	for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
> +		if (checkbuffermode(bp, "compile") == TRUE)
> +			goto done;

since now there is checkbuffermode() (which i think it's a good thing!),
this goto can become just a break.

> +	}
> + done:
> [...]

> On Thu, Aug 1, 2024, at 2:43 PM, Dante Catalfamo wrote:
> > I think this approach makes sense, although there can be two compile 
> > buffers, *grep* and *compile*.

You're right, here we pick the first buffer found while before we used
the last one created by M-x grep or compile.  I came up with this
because i don't like how we keep a pointer to a buffer that can be
killed at any moment.

as an alternative we could register a callback and make killbuffer()
invoke it so that grep.c can manage its state better.