> it probably also cannot be the default

Agree

> What if the clipboard already has indentation for the subsequent lines?
> ...

Good point, nice dissection of the problem.

----

I would go with a rather simplistic algo, that IMO covers a lot of cases 
without trying to be too smart:

```
During pasting, 
if text before cursor is only whitespace then:

- If every clipboard line has non-zero indentation,  
  then strip it until any line becomes "unindented"; ignore empty lines
    - unless "preserve_source_indentation" is set to "yes" - then don't strip 
anything
- Prefix every clipboard line with the current_line's indenation level
```

In pseudo code:

```

IF current_line.text_before_cursor IS whitespace THEN
        IF EVERY clipboard.lines STARTS_WITH whitespace THEN
                IF preferences.preserve_source_indentation == false THEN
                        strip_indentation(clipboard)
                END IF
                
                FOREACH line IN clipboard.lines
                        line = current_line.text_before_cursor + line
                END FOREACH
        END IF
END IF
```


-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/3845#issuecomment-2068200842
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/issues/3845/2068200...@github.com>

Reply via email to