Note, line breaking does not break lines when typing adds characters before the 
column limit, even if that pushes characters on the line past the limit.

Why?

Its complicated, let me show why.

In the following | means the breaking column and the successive snippets 
separated by blank lines are the progressive results of typing the x characters.

Naive line breaking inserting a newline before the last word when the line 
exceeds the limit:

```
aaa bbb ccc|
ddd        |

xaaa bbb   |
ccc        |
ddd        |

xxxxxaaa   |
bbb        |
ccc        |
ddd        |

```

oops, probably wanted the sequence:

```
xaaa bbb   |
ccc ddd    |

xxxxxaaa   |
bbb ccc    |
ddd        |
```

This is called "reflow" as provided by `Edit->Format->Reflow Lines/Block` and 
is a fine thing for text files if limited to a paragraph.

But as soon as it anything other than plain text, even mostly text like 
markdown it can break the markup, eg consider a line containing a `#` 
character, if it happens to reflow to the start of a line suddenly your 
paragraph has a heading in the middle of it!

And its even worse with code, although many languages don't care about embedded 
line breaks most of the time, all do care inside string quotes, and there are 
even more subtle issues with some languages:

```
starting with and typing x
a = 1 + 2|

Python
xa = 1 + |
2

Go
xxxa = 1 |
+ 2      |
```

The python result is illegal, but more insidiously the Go example is legal, but 
assigns 1 to the variable and calculates the expression 2 as a separate 
statement that does nothing.

So since simple automatic line breaking when typing before the limit is so 
often wrong Geany does not provide it, although it provides the facility to 
break when typing past the limit when the user has immediate visibility of the 
result and can fix any problems.  Also the user can manually apply reflow.

 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/discussions/3718#discussioncomment-7837294
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/repo-discussions/3718/comments/[email protected]>

Reply via email to