Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtfx-background-color spans if there is only one character between two styles #717

Closed
appsofteng opened this issue Apr 1, 2018 · 3 comments
Labels

Comments

@appsofteng
Copy link

Expected Behavior

When setting a style of CodeArea the background should span only the required positions.

Actual Behavior

When there is one character between two styles with background then the character without style also gets the background. In the picture the first b and space should be without background.

background

Reproducible Demo

import java.util.List;

import org.fxmisc.richtext.CodeArea;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class JFXDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        CodeArea codeArea = new CodeArea("aba abba");
        codeArea.getStylesheets().add(getClass().getResource("fx.css").toExternalForm());
        codeArea.setStyle(0, 1, List.of("mystyle"));
        codeArea.setStyle(2, 3, List.of("mystyle"));
        
        codeArea.setStyle(4, 5, List.of("mystyle"));
        codeArea.setStyle(7, 8, List.of("mystyle"));        
        
        StackPane root = new StackPane();
       
        root.getChildren().add(codeArea);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.show();

    }
}
.mystyle {
	-fx-fill: red;
	-rtfx-background-color: #ccc;
}

Environment info:

  • RichTextFX Version: 0.8.2
  • Operating System: Windows 7
  • Java version: 10
@JordanMartinez
Copy link
Contributor

Thanks for reporting!

The issue is caused by these two lines

@JordanMartinez
Copy link
Contributor

I made another snapshot release that includes this fix

@appsofteng
Copy link
Author

Works fine, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants