pgindent vs variable declaration across multiple lines

Поиск
Список
Период
Сортировка
От Andres Freund
Тема pgindent vs variable declaration across multiple lines
Дата
Msg-id 20230120013137.7ky7nl4e4zjorrfa@awork3.anarazel.de
обсуждение исходный текст
Ответы Re: pgindent vs variable declaration across multiple lines  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: pgindent vs variable declaration across multiple lines  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Hi,

There's a few places in the code that try to format a variable definition like this

    ReorderBufferChange *next_change =
        dlist_container(ReorderBufferChange, node, next);

but pgindent turns that into

    ReorderBufferChange *next_change =
    dlist_container(ReorderBufferChange, node, next);

even though the same pattern works, and is used fairly widely for assignments

    amroutine->amparallelvacuumoptions =
        VACUUM_OPTION_PARALLEL_BULKDEL;

Particularly when variable and/or types names are longer, it's sometimes hard
to fit enough into one line to use a different style. E.g., the code I'm
currently hacking on has

            RWConflict  possibleUnsafeConflict = dlist_container(RWConflictData, inLink, iter.cur);

There's simply no way to make break that across lines that doesn't either
violate the line length limit or makes pgindent do odd things:

too long line:
            RWConflict  possibleUnsafeConflict = dlist_container(RWConflictData,
                                                                 inLink,
                                                                 iter.cur);

pgindent will move start of second line:
            RWConflict  possibleUnsafeConflict =
                dlist_container(RWConflictData, inLink, iter.cur);

I know I can leave the variable initially uninitialized and then do a separate
assignment, but that's not a great fix. And sometimes other initializations
want to access the variable alrady.


Do others dislike this as well?

I assume we'd again have to dive into pg_bsd_indent's code to fix it :(

And even if we were to figure out how, would it be worth the
reindent-all-branches pain? I'd say yes, but...

Greetings,

Andres Freund



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jacob Champion
Дата:
Сообщение: Re: Experiments with Postgres and SSL
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pgindent vs variable declaration across multiple lines