bugGNU nano - Bugs: bug #47684, unindenting destroys relative...


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

bug #47684: unindenting destroys relative indentation

Submitted by:  Benno Schulenberg <bens>
Submitted on:  Wed 13 Apr 2016 08:27:33 AM UTC  
Severity:  3 - Normal Status:  Fixed
Assigned to:  David Lawrence Ramsey <dolorous> Open/Closed:  Closed

( Jump to the original submission)

Sun 10 Dec 2017 07:30:41 PM UTC, comment #6: 

Commit eb937f81 put things in the state that the original report envisioned: 1) when a line starts with a partial indent, an unindent removes it; and 2) when a line starts with a full indent followed by a partial indent, an unindent just removes the full indent and leaves the partial indent alone.  This retains relative indentations as long as all selected lines begin with at least one full indent, but allows to quickly equalize the indentations of selected lines when the user wants to.  My later idea, to limit the permissions of the unindent command, just gets in the way of the user.

Benno Schulenberg <bens>
Project Administrator
Wed 16 Aug 2017 05:08:32 PM UTC, comment #5: 

Fixed in git, 0f4716e1.  Thanks for the overhaul.

Benno Schulenberg <bens>
Project Administrator
Tue 11 Jul 2017 09:12:55 AM UTC, comment #4: 

See http://lists.gnu.org/archive/html/nano-devel/2017-07/msg00003.html for the first iteration of David's patch set.

Benno Schulenberg <bens>
Project Administrator
Sun 09 Jul 2017 02:12:17 AM UTC, comment #3: 

Actually, never mind that patch set.  Locally, I've adjusted it some more, and after some study of how commenting does it, I've been able to experimentally hook indent/unindent up to the undo/redo code (still testing that), and it seems like something that should go to the mailing list instead of here.

David Lawrence Ramsey <dolorous>
Project MemberIn charge of this item.
Fri 07 Jul 2017 11:49:25 PM UTC, comment #2: 

Sounds good to me.

The attached patch set against current git (5bc4abe) cleans up and splits up the indent/unindent functions; tweaks the behavior of both to add or remove indents from the beginnings of lines, and to only operate on full indents; and finally makes some preparations for undo integration.

(The last of these borrows from do_comment(), in that trying to indent only the magicline is now blocked with a warning.  It also borrows from comment_line(), in that trying to indent/unindent multiple lines including the magicline now silently leaves the magicline out.  The latter is more of a convenience, but I figured it was more consistent that way.)

Indent/unindent still isn't undoable, but I hope this can at least be a basis for when it is.

(file #41151)

David Lawrence Ramsey <dolorous>
Project MemberIn charge of this item.
Sat 23 Apr 2016 09:50:00 AM UTC, comment #1: 

Thinking this through again, I now think that nano should 1) leave partial indents alone (any series of leading spaces that is less than the tab width and is not followed by a tab), 2) when adding an indentation step, it should add the tab at the start of the line, not where the non-whitespace characters start, 3) when multiple lines are selected, it should only unindent if they can all be unindented, it should not change the relative indentation of the lines among themselves.

See also https://lists.gnu.org/archive/html/nano-devel/2016-04/msg00068.html.

Benno Schulenberg <bens>
Project Administrator
Wed 13 Apr 2016 08:27:33 AM UTC, original submission:  

When a line starts with only spaces (less than eight), M-{ (unindent) does not recognize this as an indentation and does not remove them.  But when you first type M-} and then M-{, the spaces are removed together with the tab that was added after them by M-}.

Also, when you type spaces (less than eight) after a tab, then M-{ will remove them together with the tab.  This is wrong: spaces after a tab should be considered a separate indentation step and should be removed separately, just as when it are eight spaces.

To reproduce, run 'nano --ignore', type <space> <space> xx M-{.  Nothing happens.  Type M-} M-{.  The two spaces are removed.

Expected behavior: M-{ removes a series of one to eight spaces in a single step, just like it removes a series of one to seven spaces followed by a tab in a single step.

Benno Schulenberg <bens>
Project Administrator


Attached Files
file #41151:  indent-overhaul.zip added by dolorous (10KiB - application/zip)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by dolorous (Updated the item)
  • -email is unavailable- added by bens (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-08-28 bens Open/ClosedOpen => Closed
    2017-08-16 bens StatusIn Progress => Fixed
    2017-07-11 bens StatusNone => In Progress
        Assigned toNone => dolorous
        Summaryunindent is not working properly => unindenting destroys relative indentation
    2017-07-07 dolorous Attached File- => Added indent-overhaul.zip, #41151

    Back to the top

    Powered by Savane 3.5