Bug 501362 - When `$(command -v kwrite)` is set as the value of `$Env:EDITOR`, `systemctl edit` generates an empty, useless tab alongside the expected one.
Summary: When `$(command -v kwrite)` is set as the value of `$Env:EDITOR`, `systemctl ...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: kwrite (show other bugs)
Version: 24.12.3
Platform: Fedora RPMs Linux
: NOR minor
Target Milestone: ---
Assignee: KWrite Developers
URL: https://discuss.kde.org/t/disable-kde...
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-11 15:19 UTC by Roke Julian Lockhart Beedell
Modified: 2025-03-17 09:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
A Screenshot of KWrite `24.12.3-1.fc41.x86_64`'s Tabs for Comment 0. (104.39 KB, image/png)
2025-03-11 15:19 UTC, Roke Julian Lockhart Beedell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roke Julian Lockhart Beedell 2025-03-11 15:19:08 UTC
Created attachment 179307 [details]
A Screenshot of KWrite `24.12.3-1.fc41.x86_64`'s Tabs for Comment 0.

SUMMARY
-------

When I invoke `systemctl --user edit plasma-powerdevil.service` with `$Env:EDITOR` set to `$(command -v kwrite)`, the expected (`.conf`) content opens in another, empty tab labelled “+4” appears too: [^1]

[1]: https://discuss-cdn.kde.org/uploads/default/original/3X/8/b/8bbddb728e4ec2c00b134f8b4132d691cd83c56e.png

Additionally, the name of the tab does not correspond to the relevant `.conf` file's filename.

STEPS TO REPRODUCE
------------------

~~~bash
#!/usr/bin/env bash
EDITOR="$(command -v kwrite)" && \ # `/usr/bin/kwrite`
systemctl --user edit plasma-powerdevil.service
~~~

EXPECTED RESULT
---------------

I should see solely one tab, and its name should correspond to the filename in the CLI.

SOFTWARE/OS VERSIONS
--------------------

I'm using `kwrite-24.12.3-1.fc41.x86_64`. Regarding the OS & DE:

1.	~~~YAML
	#!/usr/bin/env sh
	kinfo
	~~~

2.	> ~~~YAML
	> Operating System: Fedora Linux 41
	> KDE Plasma Version: 6.3.2
	> KDE Frameworks Version: 6.11.0
	> Qt Version: 6.8.2
	> Kernel Version: 6.13.5-200.fc41.x86_64 (64-bit)
	> Graphics Platform: Wayland
	> Processors: 12 × AMD Ryzen 5 7600X 6-Core Processor
	> Memory: 30.4 GiB of RAM
	> Graphics Processor 1: AMD Radeon RX 5700
	> Graphics Processor 2: AMD Radeon Graphics
	> ~~~

ADDITIONAL INFORMATION
----------------------

[^1]: [`discuss-cdn.kde.org/uploads/default/original/3X/8/b/8bbddb728e4ec2c00b134f8b4132d691cd83c56e.png`][1]
Comment 1 Roke Julian Lockhart Beedell 2025-03-11 15:24:22 UTC
> comment #0

I forgot to add the damned most important part - the cause. As [`discuss.kde.org/t/25134/15`][1] states:

> Yea, that a `systemctl` optimization for Nano that prepends `+{line-numer}` to the file name to get the
> editor to start at the specified line. The Kate-ism for this is to postfix the line number to the filename
> with a colon (i.e. `{filename}:{line-number}`), but my favorite terminal text editor - `mcedit` supports
> both the `+` syntax and the `:` syntax, so maybe Kate can be convinced to also support both.

[1]: https://discuss.kde.org/t/disable-kde-monitor-brightness-control/25134/15?u=rokejulianlockhart
Comment 2 Oded Arbel 2025-03-11 15:31:14 UTC
The presented file name being some kind of auto-generated temporary file (e.g. `.../.#override.conf13545878` or some such) is fine - this is `systemctl` generating a temporary file where it can add all the extra comments. Other editors also show the same behavior, and it is not a bug.

The feature request here is for Kate/kwrite to support the CLI options "+{line-number} {filename}" to open {filename} at line {line-number}, in addition to the current support of "{filename}:{linenumber}", as it appears that some system tools use that syntax successfully with Nano and other command line editors.
Comment 3 Roke Julian Lockhart Beedell 2025-03-14 22:51:24 UTC
(In reply to Oded Arbel from comment #2)  
> The feature request here is for Kate/kwrite to support the CLI options "+{line-number} {filename}" to open {filename} at line {line-number}, in addition to the current support of "{filename}:{linenumber}", as it appears that some system tools use that syntax successfully with Nano and other command line editors.

I'll probably have to refile this due to https://bugs.kde.org/show_bug.cgi?id=501354#c4, so I'll combine that with it when I do.
Comment 4 Bug Janitor Service 2025-03-15 19:45:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1753
Comment 5 Waqar Ahmed 2025-03-17 07:28:29 UTC
Git commit 47ff616f309d392fcde7524eb5e70413f41f45d2 by Waqar Ahmed, on behalf of Christoph Cullmann.
Committed on 17/03/2025 at 07:28.
Pushed by waqar into branch 'master'.

support +xyz line number as first argument

CHANGELOG: Kate/KWrite supports 'kate +123 test.txt' to jump to the given line

M  +22   -7    apps/kate/main.cpp
M  +10   -8    apps/lib/kateapp.cpp
M  +23   -0    apps/lib/urlinfo.h

https://invent.kde.org/utilities/kate/-/commit/47ff616f309d392fcde7524eb5e70413f41f45d2
Comment 6 Roke Julian Lockhart Beedell 2025-03-17 09:59:04 UTC
(In reply to Waqar Ahmed from comment #5)  
Thank you!