Skip to content

setClearWhitespaceLinesEnabled doesn't work if auto-indent is disabled #469

Closed
@pskowronek

Description

@pskowronek

Description
When setClearWhitespaceLinesEnabled is enabled and setAutoIndentEnabled is disabled then spaces are not being cleared when Enter is hit.

Steps to Reproduce

  • Modify src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java in the following way:
--- a/RSyntaxTextAreaDemo/src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java
+++ b/RSyntaxTextAreaDemo/src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java
@@ -210,7 +210,10 @@ public class DemoRootPane extends JRootPane implements HyperlinkListener,
                textArea.requestFocusInWindow();
                textArea.setMarkOccurrences(true);
                textArea.setCodeFoldingEnabled(true);
-               textArea.setClearWhitespaceLinesEnabled(false);
+               textArea.setWhitespaceVisible(true);
+               textArea.setClearWhitespaceLinesEnabled(true);
+               textArea.setTabsEmulated(true);
+               textArea.setAutoIndentEnabled(false);
 
                InputMap im = textArea.getInputMap();
                ActionMap am = textArea.getActionMap();
  • run ./gradlew RSyntaxTextAreaDemo:run
  • go to empty line, add some spaces and hit enter

Expected behavior
The spaces are cleared when enter is hit.

Actual behavior
The spaces are left uncleared.

Screenshots
obraz

Java version

java 14.0.2 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

OS
macOS 10.15.7

Additional context

Additional remarks:

  • when auto-indent is on, the line is cleared and spaces are being 'moved' to new line - probably this is expected behavior? Or not?
  • is there any option btw to remove trailing spaces?

Activity

changed the title [-]setClearWhitespaceLinesEnabled doesn't work auto-ident is disabled[/-] [+]setClearWhitespaceLinesEnabled doesn't work if auto-ident is disabled[/+] on Nov 30, 2022
changed the title [-]setClearWhitespaceLinesEnabled doesn't work if auto-ident is disabled[/-] [+]setClearWhitespaceLinesEnabled doesn't work if auto-indent is disabled[/+] on Nov 30, 2022
self-assigned this
on Dec 1, 2022
added this to the 3.3.1 milestone on Dec 1, 2022
bobbylight

bobbylight commented on Dec 1, 2022

@bobbylight
Owner

Thanks for reporting this! To answer your questions:

when auto-indent is on, the line is cleared and spaces are being 'moved' to new line - probably this is expected behavior? Or not?

Yes, the idea with that combination is the indent of the prior line (being cleared) is the indent that should be used for subsequent lines, so it is essentially moved to the new line.

is there any option btw to remove trailing spaces?

Not currently, but feel free to open a new feature request if you'd be interested in this. Would you expect something to happen with each Enter press, or some sort of action that could be executed on say file save (or any arbitrary event)_?

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @pskowronek@bobbylight

      Issue actions

        setClearWhitespaceLinesEnabled doesn't work if auto-indent is disabled · Issue #469 · bobbylight/RSyntaxTextArea