Hi, Found few more bugs in new code:
A: This got bad: jeevan@ubuntu:~/pg_master$ ./install/bin/psql postgres psql (9.5devel) Type "help" for help. postgres=# \set PROMPT1 '%/[%l]%R%# ' postgres[1]=# \set PROMPT2 '%/[%l]%R%# ' postgres[1]=# select postgres[2]-# * postgres[3]-# from postgres[4]-# abc; ERROR: syntax error at or near "fromabc" LINE 1: select*fromabc; ^ postgres[1]=# postgres[1]=# postgres[1]=# \e ERROR: syntax error at or near "fromabc" LINE 1: select*fromabc; ^ postgres[1]=# select*fromabc; ERROR: syntax error at or near "fromabc" LINE 1: select*fromabc; ^ postgres[1]=# See query text in LINE 1:. This is because, you have removed addition of newline character. Related added_nl_pos. Need more investigation here. However I don't think these changes are relevant to what you wanted in this feature. Will you please explain the idea behind these changes ? Moreover, if you don't want to add newline character, then I guess entire logic related to added_nl_pos is NO more required. You may remove this variable and its logic altogether, not sure though. Also make sure you update the relevant comments while doing so. Here you have removed the code which is adding the newline but the comment there still reads: /* insert newlines into query buffer between source lines */ Need more thoughts on this. B: postgres=# \set PROMPT1 '%/[%l]%R%# ' postgres[1]=# \set PROMPT2 '%/[%l]%R%# ' postgres[1]=# \e postgres[-2147483645]-# limit 1; relname -------------- pg_statistic (1 row) postgres[1]=# postgres[1]=# select relname from pg_class limit 1; Logic related to wrapping around the cur_line counter is wrong. Actually issue is with newline variable. If number of lines in \e editor goes beyond INT_MAX (NOT sure about the practical use), then newline will be -ve which then enforces cur_line to be negative. To mimic this I have initialized newline = INT_MAX - 1. Thanks -- Jeevan B Chalke Principal Software Engineer, Product Development EnterpriseDB Corporation The Enterprise PostgreSQL Company