Skip to content

git commit dialog: Account for line wrap of text area - #9702

Draft
mbien wants to merge 1 commit into
apache:masterfrom
mbien:git-commit-update-linewrap-handling
Draft

mbien wants to merge 1 commit into
apache:masterfrom
mbien:git-commit-update-linewrap-handling

Conversation

@mbien

@mbien mbien commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

the text area for the commit message has line wrap enabled while also showing a red line as recommended line length limit. The actual text which is committed is simply based on getText() atm which does not take line wrap into account. This can lead to unintended "single line" commit messages or a combination of custom and auto-wrapped text.

This computes the line wrapped text as seen in the text area and uses it for the commit message.

Alternative approach would be to simply disable line wrap which we should consider too IMO. Esp since this is difficult to unit test. (#9703)

test helper:

Details
    static void main() {
        
        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            WrappedTextArea area = new WrappedTextArea();
            area.setLineWrap(true);
            area.setWrapStyleWord(true);
            area.setText(
                    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor"
                            + " incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,"
                            + " quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea"
                            + " commodo consequat. Duis aute irure dolor in reprehenderit in voluptate"
                            + " velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint"
                            + " occaecat cupidatat non proident, sunt in culpa qui officia deserunt"
                            + " mollit anim id est laborum.");

            JButton button = new JButton("Get Wrapped Text");
            button.addActionListener(e -> {
                try {
                    String wrapped = area.getWrappedText();
                    System.out.println("- - -");
                    System.out.println(wrapped);
                    System.out.println("- - -");
//                    System.out.println(textArea.getText());
//                    System.out.println("- - -");
                } catch (BadLocationException ex) {
                    throw new RuntimeException(ex);
                }
            });

            frame.setLayout(new BorderLayout());
            frame.add(new JScrollPane(area), BorderLayout.CENTER);
            frame.add(button, BorderLayout.SOUTH);

            frame.setSize(400, 300);
            frame.setVisible(true);
        });
    }

the text area for the commit message has line wrap enabled while also
showing a red line as recommended line length limit. The actual text
which is committed is simply based on getText() atm which does not
take line wrap into account. This can lead to unintended "single line"
commit messages or a combination of custom and auto-wrapped text.

This computes the line wrapped text as seen in the text area and uses
it for the commit message.
@mbien mbien added UI User Interface git [ci] enable versioning job ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Oct 11, 2026
@mbien
mbien marked this pull request as draft October 11, 2026 23:15
@matthiasblaesing

Copy link
Copy Markdown
Contributor

I think disabling linewrap is the better approach and this is IMHO broken. I think we have this nowhere in the IDE (guess the intention of the users based on the width of the display window).

What is more oneline commits just turn into differently broken commits. They'll turn from

Long line with too much text for the summary and not details

to

Multiline commits messages
where not seperation between
summary and detail message
is present

both are broken. So from my POV this should be closed given, that the alternative was merged.

@mbien

mbien commented Oct 13, 2026 •

Copy link
Copy Markdown
Member Author

the idea is that it commits what you see in the editor - given that the editor has a linewrap marker (technically two, both are configurable via properties) you would expect exactly that. Otherwise the red line would not make sense if the view does not match the model - and lead to unexpected results in the log.

I am aware that this has a little bug I opened it for testing purposes and to show that I explored the alternative. Disabling line wrap was the hot fix. Wanted to try to fix it properly too.

Disabling line wrap maintains the same promise to commit what you see, it is just slightly less convenient. I don't really have strong opinions here. Would have been nice-to-have.

I disagree that this is conceptually broken. The red line is there, user can decide where to line wrap. E.g user might format most of the msg automatically (e.g first lines), then paste something which should be auto wrapped based on box size. As long "what you see is what you get" is maintained its fine.

@matthiasblaesing

Copy link
Copy Markdown
Contributor

As this is still open and I consider an editor not doing what I expect broken. I voice my -1 on this.

@mbien

mbien commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

@matthiasblaesing did it do what you expect when line wrap was enabled?

@neilcsmith-net

Copy link
Copy Markdown
Member

Yes, it was broken before, but I do agree with @matthiasblaesing that the other fix is the right one (and the simpler one).

@mbien

mbien commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

wanted to turn it off if the user home matches the string found in the CSS grammar file

@matthiasblaesing

Copy link
Copy Markdown
Contributor

wanted to turn it off if the user home matches the string found in the CSS grammar file

wrong PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) git [ci] enable versioning job UI User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants