better source listing for IntelliJ to include line numbers? #158

Closed
opened 2025-12-30 01:21:37 +01:00 by adam · 2 comments
Owner

Originally created by @jstrachan on GitHub (May 7, 2024).

when running pkl test inside IntelliJ as a command we get nice links to source files in the output when things fail

e.g. the output is something like this...

at something.orOther (file://someFileURL, line 34) 

clicking on those file URLs work and the source is opened - at line 1

if we modified the output ever so slightly to be....

at something.orOther (file://someFileURL:34) 

then IntelliJ would open the file at the line 34 if you click on the above link which would help folks navigate to the source of an error/test failure more quickly

Originally created by @jstrachan on GitHub (May 7, 2024). when running `pkl test` inside IntelliJ as a command we get nice links to source files in the output when things fail e.g. the output is something like this... ``` at something.orOther (file://someFileURL, line 34) ``` clicking on those file URLs work and the source is opened - at line 1 if we modified the output ever so slightly to be.... ``` at something.orOther (file://someFileURL:34) ``` then IntelliJ would open the file at the line `34` if you click on the above link which would help folks navigate to the source of an error/test failure more quickly
adam closed this issue 2025-12-30 01:21:38 +01:00
Author
Owner

@bioball commented on GitHub (May 7, 2024):

You can use a settings file to modify how stack frames get presented. This will produce links that will get opened in IntelliJ:

amends "pkl:settings"

editor = Idea

Here's my personal one, which outputs anchors (supported by iTerm 2, not sure about other terminals)

amends "pkl:settings"

local schema: String = "idea"

// https://iterm2.com/documentation-escape-codes.html
local ESC: String = "\u{1B}"
local OSC8: String = "\(ESC)]8"
local ST: String = "\(ESC)\\"
local COLOR_DIM_BLUE: String = "\(ESC)[2;34m"
local COLOR_RESET: String = "\(ESC)[0m"

editor {
  urlScheme = "\(COLOR_DIM_BLUE)\(OSC8);;\(schema)://open?file=%{path}&line=%{line}\(ST)%{path}:%{line}\(OSC8);;\(ST)\(COLOR_RESET)"
}

Screenshot 2024-05-07 at 7 45 03 AM

@bioball commented on GitHub (May 7, 2024): You can use a [settings file](https://pkl-lang.org/main/current/pkl-cli/index.html#settings-file) to modify how stack frames get presented. This will produce links that will get opened in IntelliJ: ```groovy amends "pkl:settings" editor = Idea ``` Here's my personal one, which outputs anchors (supported by iTerm 2, not sure about other terminals) ```groovy amends "pkl:settings" local schema: String = "idea" // https://iterm2.com/documentation-escape-codes.html local ESC: String = "\u{1B}" local OSC8: String = "\(ESC)]8" local ST: String = "\(ESC)\\" local COLOR_DIM_BLUE: String = "\(ESC)[2;34m" local COLOR_RESET: String = "\(ESC)[0m" editor { urlScheme = "\(COLOR_DIM_BLUE)\(OSC8);;\(schema)://open?file=%{path}&line=%{line}\(ST)%{path}:%{line}\(OSC8);;\(ST)\(COLOR_RESET)" } ``` ![Screenshot 2024-05-07 at 7 45 03 AM](https://github.com/apple/pkl/assets/4590460/48e142d5-2969-4a39-9dd9-8ff1a7587102)
Author
Owner

@jstrachan commented on GitHub (May 8, 2024):

love that! would be good to add to the docs

@jstrachan commented on GitHub (May 8, 2024): love that! would be good to add to the docs
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#158