Skip to content

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

@appsofteng

Description

@appsofteng

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions