From 6fb13ea32175157976a6966cdce98f469ae79140 Mon Sep 17 00:00:00 2001 From: Mattia Marelli Date: Fri, 15 Nov 2024 18:20:41 +0100 Subject: [PATCH] Fix formatting issues --- .../ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java b/RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java index a0c62b546..e89ebd229 100755 --- a/RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java +++ b/RSyntaxTextArea/src/main/java/org/fife/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java @@ -2207,12 +2207,13 @@ public ToggleCommentAction() { @Override public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { + if (!textArea.isEditable() || !textArea.isEnabled()) { UIManager.getLookAndFeel().provideErrorFeedback(textArea); return; } - RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument(); + RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument(); Element map = doc.getDefaultRootElement(); Caret c = textArea.getCaret(); int dot = c.getDot(); @@ -2220,7 +2221,7 @@ public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { int line1 = map.getElementIndex(dot); int line2 = map.getElementIndex(mark); int start = Math.min(line1, line2); - int end = Math.max(line1, line2); + int end = Math.max(line1, line2); Token t = doc.getTokenListForLine(start); int languageIndex = t != null ? t.getLanguageIndex() : 0; @@ -2231,8 +2232,9 @@ public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { return; } - /* Don't toggle comment on last line if there is no text selected on it. */ - if (start != end) { + // Don't toggle comment on last line if there is no + // text selected on it. + if (start!=end) { Element elem = map.getElement(end); if (Math.max(dot, mark) == elem.getStartOffset()) { end--; @@ -2393,4 +2395,4 @@ public final String getMacroID() { } -} \ No newline at end of file +}