bobbylight / RSyntaxTextArea

A syntax highlighting, code folding text editor for Java Swing applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comma or other punctuation mark at beginning of line

Andreas0602 opened this issue · comments

Description
When you edit a txt file and line wrap is enabled, it can happen in an unfavorable case that a comma or other punctuation mark is at the beginning of a line. Similarly, it can happen that an opening parenthesis or a quotation mark is at the end of a line.

Steps to Reproduce
see screenshot below for an example

Expected behavior
For txt files, there should be no line break between a word and a directly following comma, period, semicolon, colon, hyphen etc. Also, there should be no line break between an opening parenthesis and a word.

Actual behavior
see above

Screenshots
Lorem ipsum

Parentheses

Quotation Marks

Java version
Runtime version: 23-internal
VM name: OpenJDK 64-Bit Server VM
VM version: 23-internal-ahadas-0081ac197a656cdc0d88d5a5e2a0f399ee023654
VM vendor: Oracle Corporation

Additional context
I'm a muCommander user and have originally reported this issue here: mucommander/mucommander#1197

Operating System type and version:
Name: Mac OS X
Version: 14.5
Architecture: aarch64

muC currently still uses RSyntaxTextArea v3.3.4. But, I've checked muC build with v3.4.0 and the problem is still there.

RSTA's line wrap is per-token, per the TokenMaker, and not per typical lexical rules. I think the way to do this "the right way" would be to change the PlainTextTokenMaker to use BreakIterator to break text on word instances.

I'm not sure it's worth changing the behavior in programming languages where line wrap is less common, and folks are probably more forgiving of code being wrapped baed on how the language is lexed.