From 651454170dff2c218530017589bfc84f1b3eac9a Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 28 Aug 2021 14:30:11 +0200 Subject: [PATCH] Theme Editor: - fixed duplicate lines action if selection includes line separator at the end - preview: do not disable internal components of JInternalFrame --- .../themeeditor/FlatSyntaxTextAreaActions.java | 11 +++++++++-- .../formdev/flatlaf/themeeditor/FlatThemePreview.java | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatSyntaxTextAreaActions.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatSyntaxTextAreaActions.java index 02559203..30e5321b 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatSyntaxTextAreaActions.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatSyntaxTextAreaActions.java @@ -122,8 +122,15 @@ class FlatSyntaxTextAreaActions @Override public void actionPerformedImpl( ActionEvent e, RTextArea textArea ) { try { - int selStartLine = textArea.getLineOfOffset( textArea.getSelectionStart() ); - int selEndLine = textArea.getLineOfOffset( textArea.getSelectionEnd() ); + int selStart = textArea.getSelectionStart(); + int selEnd = textArea.getSelectionEnd(); + + int selStartLine = textArea.getLineOfOffset( selStart ); + int selEndLine = textArea.getLineOfOffset( selEnd ); + + // check whether selection end is at the beginning of the next line + if( selEnd > selStart && textArea.getLineOfOffset( selEnd - 1 ) < selEndLine ) + selEndLine--; int linesStart = textArea.getLineStartOffset( selStartLine ); int linesEnd = textArea.getLineEndOffset( selEndLine ); diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java index e2625a24..2fd0db51 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePreview.java @@ -271,7 +271,7 @@ class FlatThemePreview if( comp != previewLabel && comp != enabledCheckBox ) comp.setEnabled( enabled ); - if( !(comp instanceof Container) ) + if( !(comp instanceof Container) || comp instanceof JInternalFrame ) return; for( Component c : ((Container)comp).getComponents() ) {