vscode icon indicating copy to clipboard operation
vscode copied to clipboard

[Enhancement] When `(Get-Command code).Path` is set as the value of `$Env:EDITOR`, it doesn't support `systemctl edit`.

Open RokeJulianLockhart opened this issue 9 months ago • 0 comments

Does this issue occur when all extensions are disabled?

Yes

VS Code Version

Version: 1.98.2
Commit: ddc367ed5c8936efe395cffeec279b04ffd7db78
Date: 2025-03-12T13:32:45.399Z
Electron: 34.2.0
ElectronBuildId: 11161602
Chromium: 132.0.6834.196
Node.js: 20.18.2
V8: 13.2.152.36-electron.0
OS: Linux x64 6.13.7-200.fc41.x86_64

It's code-1.98.0-1741124844.el8.x86_64:

  1. #!/usr/bin/env sh
    dnf5 info code --refresh
    
  2. Name            : code
    Epoch           : 0
    Version         : 1.98.0
    Release         : 1741124844.el8
    Architecture    : x86_64
    Installed size  : 400.0 MiB
    Source          : code-1.98.0-1741124844.el8.src.rpm
    From repository : code
    

OS Version

  1. #!/usr/bin/env pwsh
    #Requires -PSEdition Core
    Get-Content -LiteralPath /etc/os-release | Select-String -SimpleMatch CPE_NAME
    
  2. CPE_NAME="cpe:/o:fedoraproject:fedora:41"
    

Steps to Reproduce

  1. Configure the OS to match my kinfo output (which should be the default state of the KDE Spin):

    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
    

    This solely impacts whether plasma-powerdevil.service exists, because it's the example that I've chosen:

  2. #!/usr/bin/env pwsh
    #Requires -PSEdition Core
    EDITOR="$((Get-Command code).Path)" && ` # `/usr/bin/code`
    systemctl --user edit plasma-powerdevil.service
    

Result

discuss.kde.org/t/25134/13 compares it to KDE's KWrite, which ultimately supports the application (albeit not in a 100%-perfect state, but that's irrelevant in this context):

Although the file opens in kwrite-24.12.3-1.fc41.x86_64, another, empty tab labelled "+4" appears too:

  1. #!/usr/bin/env pwsh
    #Requires -PSEdition Core
    EDITOR="$((Get-Command kwrite).Path)" && ` # `/usr/bin/kwrite`
    systemctl --user edit plasma-powerdevil.service
    
  2. Image

Even more interestingly, closing the filled tab closes the other simultaneously! This doesn't occur if the opposite tab is closed first.

Multiple tabs also appear in code-1.98.0-1741124844.el8.x86_64, but the other file is empty:

  1. #!/usr/bin/env pwsh
    #Requires -PSEdition Core
    EDITOR="$((Get-Command code).Path)" && ` # `/usr/bin/code`
    systemctl --user edit plasma-powerdevil.service
    
  2. Image

This doesn't close one tab when the other does, and systemctl erroneously considers the file to have been "installed" (saved?) the moment that the code process is spawned.

Cause

A response states the undermentioned: ^2

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.

This applies to VS Code, too.

RokeJulianLockhart avatar Mar 11 '25 14:03 RokeJulianLockhart