Bug 439260

Summary: Adding a new variable should use the cursor position as reference
Product: [Frameworks and Libraries] SeExpr Reporter: Alvin Wong <alvin>
Component: GeneralAssignee: amyspark <amy>
Status: RESOLVED FIXED    
Severity: normal CC: amy
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Alvin Wong 2021-06-28 13:42:09 UTC
The last value of a script is the return value, so with an existing script appending new variable declarations at the end seems counter-intuitive. But we can't directly use the cursor position, because if the cursor is inside a line then it will break the existing line.

So I think what can happen is to insert the new variable as a new line above or below the current line the cursor is at. Whether above or below should be used needs some consideration (I think above is better).
Comment 1 amyspark 2021-06-28 23:47:41 UTC
Git commit ba6a0931c15fd49177095a76a7e0600dfd34b829 by L. E. Segovia.
Committed on 28/06/2021 at 21:49.
Pushed by lsegovia into branch 'master'.

Insert new variables above the current line

That will preserve the last line (the return value).

M  +3    -1    src/KSeExprUI/ExprEditor.cpp

https://invent.kde.org/graphics/kseexpr/commit/ba6a0931c15fd49177095a76a7e0600dfd34b829
Comment 2 Alvin Wong 2021-06-29 10:36:17 UTC
Seems like it is inserting the new variable line before the line above the current line, not just above the current line.
Comment 3 amyspark 2021-07-01 01:29:16 UTC
Git commit 5d323abb9a8e694deac7ae969f3058ad520ceed2 by L. E. Segovia.
Committed on 30/06/2021 at 21:33.
Pushed by lsegovia into branch 'master'.

Insert new variables at the start of the current line

M  +0    -1    src/KSeExprUI/ExprEditor.cpp

https://invent.kde.org/graphics/kseexpr/commit/5d323abb9a8e694deac7ae969f3058ad520ceed2