rust-lang / rust-lang/rust-mode

No indentation on function parameters when electric-pair-mode is activated

Open
#287 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

indentation
Dominant language
Emacs Lisp
Stars
1.3k
Forks
198
PR merge metrics
No merged PRs in 30d

Description

When electric-pair-mode is activated, adding function parameters on a new line results in the new line not being indented (i.e. cursor on column 0).

Example of the bug ( denotes the cursor position):

fn test‸

Typing ( will add balanced parentheses and position the cursor between the two:

fn test(‸)

Adding a parameter:

fn test(a: u8,‸)

Then using RET to insert a new line results in:

fn test(a: u8,
‸)

Ideally the final step should indent the line to be aligned on the previous parameter, producing:

fn test(a: u8,
        ‸)

Note: this doesn't happen when writing C code, even when electric-pair-mode is activated.
For example:

int func(char c,‸)

Adding a new line with RET, indentation is correct:

int func(char c,
	 ‸)

Is there a way to have the indentation when making a new line and still have electric-pair-mode?

Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example in rust-mode with electric-pair-mode enabled, then compare the newline behavior with the C example described in the issue. Trace the RET handling and indentation entry points available from rust-mode; done means a parameter line is indented to match the expected alignment while electric-pair-mode remains enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs, rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.