Skip to content

indent infinite loop in 1.2.0 #12

Open
@soos-peter-levente

Description

@soos-peter-levente

What did you expect to happen?

I attempted to indent some copy & pasted MIPS code (e.g this). I expected lines to be indented according to the current mips-mode column settings.

What actually happened?

I think a variable is never incremented and a space keeps getting added to the head of the line and I have to Ctrl+G out.

Describe your attempts to resolve the issue

mips-pad-rxg internals from before the refactor in f35e039 seem to work.

I took that and modified it to contain an untabify call and also removed the progn from the else clause, but otherwise, it's the same thing.

(defun mips--pad-rxg (column group)
  "Match a MIPS assembly statement using `mips-line-re'.

Will trim, pad, or backward-delete string segment in matching group GROUP until
COLUMN."
  (string-match mips-line-re (mips-line))
  (untabify (line-beginning-position) (line-end-position))
  (when (wholenump (match-beginning group))
    (move-to-column (match-beginning group))
    (when (< (current-column) (match-end group))
      (while (/= (current-column) column)
        (if (< (current-column) column)
          (insert mips-indent-character)
          (if (member (preceding-char) mips-wp-char)
            (delete-backward-char 1)
            (message "Bumped into a wall at column %s!" (current-column))
            (insert mips-indent-character) ;; pad one whitespace
            (move-to-column column t)      ;; and bail out forward.
            (while (member (char-after) mips-wp-char)
              (delete-forward-char 1))))))))

Steps to reproduce

  1. Copy & paste some MIPS code in a mips-mode buffer.
  2. Select a region
  3. Press Tab to indent

Package commit

98795cd

System Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions