Skip to content

Commit ecbb126

Browse files
committed
Add autocomplete accessors
See Readline::setAutocomplete() and Readline::getAutocomplete()
1 parent 340b8f0 commit ecbb126

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Readline.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,17 @@ public function setAutocomplete(Autocomplete $autocomplete)
411411
return $this;
412412
}
413413

414+
/**
415+
* Gets the current autocomplete handler in use
416+
*
417+
* @return Autocomplete
418+
* @see self::setAutocomplete()
419+
*/
420+
public function getAutocomplete()
421+
{
422+
return $this->autocomplete;
423+
}
424+
414425
/**
415426
* redraw the current input prompt
416427
*

tests/ReadlineTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,15 @@ public function testCursorCellObeysCustomEchoAsterisk(Readline $readline)
495495
$this->assertEquals(3, $readline->getCursorCell());
496496
}
497497

498+
public function testAutocompleteGetterReturnsSameFromSetter()
499+
{
500+
$autocomplete = $this->getMock('Clue\React\Stdio\Readline\Autocomplete');
501+
502+
$this->assertSame($this->readline, $this->readline->setAutocomplete($autocomplete));
503+
504+
$this->assertSame($autocomplete, $this->readline->getAutocomplete());
505+
}
506+
498507
public function testEmitEmptyInputOnEnter()
499508
{
500509
$this->readline->on('data', $this->expectCallableOnceWith(''));

0 commit comments

Comments
 (0)