Skip to content

Commit f4e7d86

Browse files
Merge branch '6.2' into 6.3
* 6.2: fix merge [DependencyInjection] Filter "container.excluded" services when using `findTaggedServiceIds()` [Cache] Removing null coalescing assignment operator on 5.4 [Console] Add missing ZSH mention in DumpCompletionCommand help [Cache] Fix storing binary keys when using pgsql [FrameworkBundle] Add missing monolog channel tag for messenger services update documentation for telegram bridge notifier [FrameworkBundle] Improve documentation about translation:extract --sort option [VarDumper] Disable links for IntelliJ platform [Notifier] Add bridge documentation [HttpClient] Add hint about `timeout` and `max_duration` options [HttpFoundation] Use separate caches for IpUtils checkIp4 and checkIp6 [FrameworkBundle] Fix wiring session.handler when handler_id is null [FrameworkBundle] Workflow - Fix LogicException about a wrong configuration of "enabled" node
2 parents 244eb2c + 3582d68 commit f4e7d86

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

Command/DumpCompletionCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ protected function configure(): void
5252
default => ['~/.bashrc', "/etc/bash_completion.d/$commandName"],
5353
};
5454

55+
$supportedShells = implode(', ', $this->getSupportedShells());
56+
5557
$this
5658
->setHelp(<<<EOH
5759
The <info>%command.name%</> command dumps the shell completion script required
58-
to use shell autocompletion (currently, bash and fish completion is supported).
60+
to use shell autocompletion (currently, {$supportedShells} completion are supported).
5961
6062
<comment>Static installation
6163
-------------------</>

Formatter/OutputFormatterStyle.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public function setOptions(array $options)
9898
public function apply(string $text): string
9999
{
100100
$this->handlesHrefGracefully ??= 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
101-
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100);
101+
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100)
102+
&& !isset($_SERVER['IDEA_INITIAL_DIRECTORY']);
102103

103104
if (null !== $this->href && $this->handlesHrefGracefully) {
104105
$text = "\033]8;;$this->href\033\\$text\033]8;;\033\\";

Tests/Formatter/OutputFormatterTest.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,10 @@ public function testFormatterHasStyles()
244244
/**
245245
* @dataProvider provideDecoratedAndNonDecoratedOutput
246246
*/
247-
public function testNotDecoratedFormatter(string $input, string $expectedNonDecoratedOutput, string $expectedDecoratedOutput, string $terminalEmulator = 'foo')
247+
public function testNotDecoratedFormatterOnJediTermEmulator(string $input, string $expectedNonDecoratedOutput, string $expectedDecoratedOutput, bool $shouldBeJediTerm = false)
248248
{
249+
$terminalEmulator = $shouldBeJediTerm ? 'JetBrains-JediTerm' : 'Unknown';
250+
249251
$prevTerminalEmulator = getenv('TERMINAL_EMULATOR');
250252
putenv('TERMINAL_EMULATOR='.$terminalEmulator);
251253

@@ -257,6 +259,35 @@ public function testNotDecoratedFormatter(string $input, string $expectedNonDeco
257259
}
258260
}
259261

262+
/**
263+
* @dataProvider provideDecoratedAndNonDecoratedOutput
264+
*/
265+
public function testNotDecoratedFormatterOnIDEALikeEnvironment(string $input, string $expectedNonDecoratedOutput, string $expectedDecoratedOutput, bool $expectsIDEALikeTerminal = false)
266+
{
267+
// Backup previous env variable
268+
$previousValue = $_SERVER['IDEA_INITIAL_DIRECTORY'] ?? null;
269+
$hasPreviousValue = \array_key_exists('IDEA_INITIAL_DIRECTORY', $_SERVER);
270+
271+
if ($expectsIDEALikeTerminal) {
272+
$_SERVER['IDEA_INITIAL_DIRECTORY'] = __DIR__;
273+
} elseif ($hasPreviousValue) {
274+
// Forcibly remove the variable because the test runner may contain it
275+
unset($_SERVER['IDEA_INITIAL_DIRECTORY']);
276+
}
277+
278+
try {
279+
$this->assertEquals($expectedDecoratedOutput, (new OutputFormatter(true))->format($input));
280+
$this->assertEquals($expectedNonDecoratedOutput, (new OutputFormatter(false))->format($input));
281+
} finally {
282+
// Rollback previous env state
283+
if ($hasPreviousValue) {
284+
$_SERVER['IDEA_INITIAL_DIRECTORY'] = $previousValue;
285+
} else {
286+
unset($_SERVER['IDEA_INITIAL_DIRECTORY']);
287+
}
288+
}
289+
}
290+
260291
public static function provideDecoratedAndNonDecoratedOutput()
261292
{
262293
return [
@@ -267,7 +298,7 @@ public static function provideDecoratedAndNonDecoratedOutput()
267298
['<fg=red>some text with inline style</>', 'some text with inline style', "\033[31msome text with inline style\033[39m"],
268299
['<href=idea://open/?file=/path/SomeFile.php&line=12>some URL</>', 'some URL', "\033]8;;idea://open/?file=/path/SomeFile.php&line=12\033\\some URL\033]8;;\033\\"],
269300
['<href=https://example.com/\<woohoo\>>some URL with \<woohoo\></>', 'some URL with <woohoo>', "\033]8;;https://example.com/<woohoo>\033\\some URL with <woohoo>\033]8;;\033\\"],
270-
['<href=idea://open/?file=/path/SomeFile.php&line=12>some URL</>', 'some URL', 'some URL', 'JetBrains-JediTerm'],
301+
['<href=idea://open/?file=/path/SomeFile.php&line=12>some URL</>', 'some URL', 'some URL', true],
271302
];
272303
}
273304

0 commit comments

Comments
 (0)