bugGNU nano - Bugs: bug #62789, [Wish] prevent the formatter from...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #62789: [Wish] prevent the formatter from flashing the screen

Submitter:  Gert Cuykens <gert>
Submitted:  Wed 20 Jul 2022 12:25:04 PM UTC
   
 
Severity:  1 - Wish Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Jump to the original submission

Wed 03 Aug 2022 06:01:59 AM UTC, comment #11: 

The change was released in nano-6.4.

Benno Schulenberg <bens>
Group administrator
Mon 25 Jul 2022 02:41:33 PM UTC, comment #10: 

(There will be a release next week, if all goes well.)

Benno Schulenberg <bens>
Group administrator
Mon 25 Jul 2022 02:40:09 PM UTC, comment #9: 

Fixed in git, commit bb18524c, by calling full_refresh() instead of exiting and re-entering curses mode.

Benno Schulenberg <bens>
Group administrator
Fri 22 Jul 2022 06:35:27 AM UTC, comment #8: 

Thanks for testing.  I've posted the patch to nano-devel, just in case someone has objections.  When not, it will get applied in three days.

Benno Schulenberg <bens>
Group administrator
Thu 21 Jul 2022 08:01:20 PM UTC, comment #7: 

Patch applied on 6.3 tar xz, compiled and tested, works perfect, ship it :) thanks

Gert Cuykens <gert>
Thu 21 Jul 2022 03:14:40 PM UTC, comment #6: 

Please try the attached patch and see whether it works the way you wish.

(By the way, pylint can be used with nano when using the --exit-zero option.)

(file #53461)

Benno Schulenberg <bens>
Group administrator
Thu 21 Jul 2022 02:30:13 PM UTC, comment #5: 

Not exiting from curses mode sounds good, but... there are formatters (like 'tidy') that will sometimes produce output even when --quiet is used.  To see what I mean, apply the attached patch (that basically reverts commit 2b9f0619), compile, then run:

src/nano doc/cheatsheet.html

Then type: M-F
See that there are some lines of "garbage" like this:

line 23 column 1 - Warning: <table> lacks "summary" attribute

Type M-F again.  Still more garbage appears.  As ncurses does not know that those strings are there, calling edit_refresh() will not help to clear them away.  That was the reason why commit 2b9f0619 was made: exit from curses mode while running the formatter.

But now I realize that a call of full_refresh() instead would clear any garbage from the formatter...

(file #53460)

Benno Schulenberg <bens>
Group administrator
Wed 20 Jul 2022 10:54:15 PM UTC, comment #4: 

After testing some more with the linter using the nano recommended pyflakes that works out of the box, I agree it should be the tool that should adjust to nano, not the other way around. I would say any formatter either works or it doesn't, so it should just display a messages based on exit status and either buffer is modified or not. No need for stdout or stderr, it's irrelevant for a formatter, if you want to know the stdout you should run formatter in your terminal directly. Keep nano as simple as possible so no exit from ncurses, just 3 message [error|change|no change]

Gert Cuykens <gert>
Wed 20 Jul 2022 09:24:46 PM UTC, comment #3: 

In terminal running
pylint ~/Desktop/py/format.py
shows ...
Desktop/py/format.py:21:0: C0413: Import "from string import Template" should be placed at the top of the module (wrong-import-position)
...

In nano 6.3 linter pylint
will result in no flash and a error message
[error invoking 'pylint']
but the output is lost of pylint

In nano 6.3 set speller pylint
will result in flash and a error message
[ Error invoking 'pylint' ]
but the output can be retrieved suspending nano with C-z

In terminal running
black ~/Desktop/py/format.py
shows
All done! ✨ 🍰 ✨
1 file reformatted.
reformatted ~/Desktop/py/format.py

In nano 6.3 formatter black
will result in flash and a message
[buffer has been processed]
but the output can be retrieved suspending nano with C-z

========

Maybe spell, linter and formatter should be made consistent preferably running the same c functions. Maybe a dedicated stdout/err buffer that is accessible with for example M-> and then all strings in that buffer that match a configurable location format should be highlighted and when you press a key on them nano jumps to the other buffer location

Gert Cuykens <gert>
Wed 20 Jul 2022 01:46:18 PM UTC, comment #2: 

Exiting from ncurses serves to accommodate those formatters that always produce output or require user interaction.  See
https://git.savannah.gnu.org/cgit/nano.git/commit/?id=2b9f0619.  Whether that is worth it?  I can't judge as I never use the feature and have no idea what formatting programs generally do.

Benno Schulenberg <bens>
Group administrator
Wed 20 Jul 2022 01:01:12 PM UTC, comment #1: 

Not flashing the screen when the formatter runs would indeed be good.  In an earlier incarnation (commit e39938c1), nano would not flash and instead let any output from the formatter overwrite the stuff on the screen, and would pause for four seconds if the formatter reported an error, to allow the user to read it.  Would this suit you?

(This pausing mechanism got lost when do_formatter() was deleted and later reimplemented using the same routine as used for external spell checking, and external spell checking needs to exit from ncurses, which makes flashing the screen unavoidable.)  (By the way, running the linter does not flash.)

Benno Schulenberg <bens>
Group administrator
Wed 20 Jul 2022 12:25:04 PM UTC, original submission:  

example nano, version 6.3
Compiled options: --disable-libmagic --enable-utf8

## Syntax highlighting for Python.
formatter black

When running formatter on python file using the M-f
it will flash the console prompt and back even if you do black -q and there is no stdout or error from black

If technically possible option to safe stdout/stderr in hidden background buffer to prevent flash

Gert Cuykens <gert>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by gert (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-03 bens Open/ClosedOpen Closed
    2022-07-25 bens StatusIn Progress Fixed
    2022-07-22 bens StatusReady For Test In Progress
    2022-07-21 bens Summary[Wish] prevent the formatter from flashing the screen when no output [Wish] prevent the formatter from flashing the screen
    2022-07-21 bens Attached File- Added 0001-formatter-instead-of-leaving-curses-use-full_refresh.patch, #53461
        StatusNone Ready For Test
        Assigned toNone bens
    2022-07-21 bens Attached File- Added dont-exit-from-curses-for-formatter.patch, #53460
    2022-07-20 bens Severity3 - Normal 1 - Wish
        Summaryprevent formatter or linter screen flash stdout [Wish] prevent the formatter from flashing the screen when no output

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code