Skip to content

Set cursor on startup improvements

I was advised by Dominik Haumann to use a lambda function in connect(). This syntax was not trivial for me so I resorted to the syntax I see all over in kate 20.12 for the time being (i.e. SIGNAL() and SLOT()). I'll research this and improve on it in a next iteration if expected or recommended.


The handling of cursor position at startup is inconsistent in 20.12.

Cursor position passed in command line arguments is only set in the last document when opening multiple.

When opening a session with --line/--column on the command line, cursor is first set from session (or query string), then reset from args.

Cursor position info may come from 3 places: session, args or query string. I think it's obvious that when considering which one to use the order should be query string, or if no query string, then args, or if no args, then session.

This patch addresses bug 335608 and the above inconsistencies.


Test case: kate has a session 's2' with 2 local files open 'local2' and 'local3' with cursor on line 2 and line 3 respectively. Kate has no open instance.

After command:

$ kate --start s2 --line 4 local2

the cursor is on line 4 in 'local2' (from args) and on line 3 in 'local3' because it was opened from session (local3 is not in command line).

After command

$ kate --start s2 --line 4 local2 local3

the cursor is on line 4 in both files.

After command

$ kate --start s2 --line 4 file:///local2?line=5

the cursor is on line 5 in 'local2' (query overrode args) and on line 3 in 'local3' (from session). (Query strings only work with full absolute local pathnames.)

After command

$ kate --start s2 --line 4 file:///local2?line=5 local3

the cursor is on line 5 in 'local2' (query) and on line 4 in 'local 3' (args) (session was overridden in both).

Test case is reset before each command.


Test case: kate has a session 's3' with one local file 'ignore' and two remote files 'remote2' and 'remote3'. The cursor in the remote files is on line 2 and line 3 respectively. Kate has no open instance.

Fixed in 29461ad5 (There is a bug: when a session with a remote file being the active document is restored, the cursor is reset to 0,0 in the doc. To overcome this for this test, the local file is active in the session.)

(The query string is ignored on remote files, not parsed, not stripped from the file path and becomes part of the doc.url display string. Therefore, it is not tested with remote files.)

Update for the above: The described behaviour is true for local files only when passed in w/o the file:// prefix e.g. ~/file1?line=3 but that's OK since it's a valid file name and query strings with protocol are supported. Tests above for local files should now pass the same way for remotes.

After command

$ kate --start s3 --line 4 fish://host/remote2

the cursor is on line 4 in 'remote2' (from args) and on line 3 in 'remote3' (from session).

After command

$ kate --start s3 --line 4 fish://host/remote2 fish://host/remote3

the cursor is on line 4 in both files.

Edited by Marcell Fulop

Merge request reports