8000 Clickable line number when using `editorUrl` by ruudk · Pull Request #526 · phpstan/phpstan-src · GitHub
[go: up one dir, main page]

Skip to content

Clickable line number when using editorUrl #526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

ruudk
Copy link
Contributor
@ruudk ruudk commented May 17, 2021

Fixes phpstan/phpstan#5013

I like the editorUrl feature a lot. Unfortunately, it didn't work on small terminals as the line would be wrapped and breaking the link.

I found out that Symfony has support for Console Hyperlinks. We can use them to make the line number clickable instead.

I think it looks a lot cleaner and more intuitive:

Screenshot 2021-05-17 at 19 01 59@2x

⚠️ I had to remove the table wrapper code as the wordwrap method doesn't take formatting / decoration into account. I hope this is OK.

ruudk added 2 commits May 17, 2021 18:59
@ondrejmirtes
Copy link
Member

Hi, thanks!

  I had to remove the table wrapper code

I don't think this will fly. It would make the output much worse. Instead, the word wrapping code should only be applied to the message as the error line string is unlikely to be very long.

I'm also a bit worried about terminals that do not support this. Having to study the whole article and the comments here makes me shiver: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

@ondrejmirtes ondrejmirtes force-pushed the master branch 2 times, most recently from efd31ce to 0471f87 Compare July 29, 2021 14:08
@enumag
Copy link
Contributor
enumag commented Aug 17, 2021

Perhaps a bit off topic but in case anyone is interested I've been using links with phpstan for a long time now using https://github.com/grifart/phpstan-oneline with a configuration like this:

services:
	errorFormatter.compact:
		class: Grifart\PhpstanOneLine\CompactErrorFormatter
		arguments:
			format: "�]8;;phpstorm://open/?file=___{absolutePath}&line={line}�\\{path}:{line}�]8;;�\\\n ↳ {error}\n"
docker-compose run php sh -c "bin/console --quiet && vendor/bin/phpstan analyse --ansi --error-format=compact --verbose | sed \"s~___/app~$$PWD~g\""

The hack with ___ and sed is to fix the paths for PHPStorm since I'm running phpstan inside a docker container where the paths are different. It gets easier if docker is not involved.

This is in fact using the thing that @ondrejmirtes linked.

I didn't bother to study in which terminals it works or not. The important thing is that I successfully lobbied JetBrains into supporting it in PHPStorm terminal and that's enough for me and my team.

@ruudk ruudk closed this Jan 11, 2022
@ruudk ruudk deleted the clickable-line-number branch January 11, 2022 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editor URL output should not be wrapped
3 participants
0