From 8f5986e91e867b2302c9260558a788a186e0e417 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 14 Apr 2021 13:24:13 -0400 Subject: [PATCH] Resolve merge conflict --- src/Document.php | 4 +- src/Row.php | 17 +- tests/ANSITest.php | 2 +- tests/EditorTest.php | 4 +- tests/RowTest.php | 24 +- tests/TermiosTest.php | 2 +- .../EditorTest__testOpen__1.json | 290 +++++++++++++----- 7 files changed, 245 insertions(+), 98 deletions(-) diff --git a/src/Document.php b/src/Document.php index 0127982..4484646 100644 --- a/src/Document.php +++ b/src/Document.php @@ -223,7 +223,7 @@ class Document { $newChars = substr($chars, 0, $at->x); // Truncate the previous row - $row->chars = $newChars; + $row->setChars($newChars); // Add a new row with the contents of the previous row at the point of the split $this->insertRow($at->y + 1, substr($chars, $at->x)); @@ -255,7 +255,7 @@ class Document { public function refreshSyntax(): void { // Update the syntax highlighting for all the rows of the file - array_walk($this->rows, static fn (Row $row) => $row->highlight()); + array_walk($this->rows, static fn (Row $row) => $row->update()); } private function refreshPHPSyntax(): void diff --git a/src/Row.php b/src/Row.php index 4e05e85..58ba1b3 100644 --- a/src/Row.php +++ b/src/Row.php @@ -11,7 +11,7 @@ use Aviat\Kilo\Enum\RawKeyCode; * @property string $chars */ class Row { - use Traits\MagicProperties; + // use Traits\MagicProperties; /** * The version of the row to be displayed (where tabs are converted to display spaces) @@ -89,15 +89,6 @@ class Row { }; } - public function __set(string $name, mixed $value): void - { - if ($name === 'chars') - { - $this->chars = $value; - $this->highlight(); - } - } - /** * Convert the row contents to a string for saving * @@ -187,6 +178,12 @@ class Row { $this->parent->dirty = true; } + public function setChars(string $chars): void + { + $this->chars = $chars; + $this->update(); + } + /** * Convert tabs to spaces for display, and update syntax highlighting */ diff --git a/tests/ANSITest.php b/tests/ANSITest.php index f4293f5..672b5e9 100644 --- a/tests/ANSITest.php +++ b/tests/ANSITest.php @@ -1,6 +1,6 @@ markTestSkipped(); - $editor = MockEditor::mock('src/ffi.h'); $state = json_encode($editor->__debugInfo(), JSON_THROW_ON_ERROR); diff --git a/tests/RowTest.php b/tests/RowTest.php index 70cd871..103dfc3 100644 --- a/tests/RowTest.php +++ b/tests/RowTest.php @@ -1,6 +1,6 @@ document = Document::new(); - $this->row = Row::new($this->document, '', 0); + $this->document->insertRow(0, ''); + + $this->row = $this->document->rows[0]; } public function testSanity(): void @@ -31,17 +33,17 @@ class RowTest extends TestCase { public function testSetRunsUpdate(): void { - $this->markTestSkipped('Hangs'); - - $this->row->chars = 'abcde'; - $this->assertEquals('abcde', $this->row->render); + // $this->markTestSkipped('Hangs'); + $this->row->setChars('abcde'); + // $this->assertNotEmpty($this->row->chars); + // $this->assertEquals('abcde', $this->row->render); } public function test__toString(): void { $this->markTestSkipped('Hangs'); - $this->row->chars = 'abcde'; + $this->row->setChars('abcde'); $this->assertEquals("abcde\n", (string)$this->row); } @@ -64,7 +66,7 @@ class RowTest extends TestCase { { $this->markTestSkipped('Hangs'); - $this->row->chars = 'abde'; + $this->row->setChars('abde'); $this->row->insert(2, 'c'); $this->assertEquals('abcde', $this->row->chars); @@ -76,7 +78,7 @@ class RowTest extends TestCase { { $this->markTestSkipped('Hangs'); - $this->row->chars = 'ab'; + $this->row->setChars('ab'); $this->row->insert(5, 'c'); $this->assertEquals('abc', $this->row->chars); @@ -88,7 +90,7 @@ class RowTest extends TestCase { { $this->markTestSkipped('Hangs'); - $this->row->chars = 'abcdef'; + $this->row->setChars('abcdef'); $this->row->delete(5); $this->assertEquals('abcde', $this->row->chars); @@ -100,7 +102,7 @@ class RowTest extends TestCase { { $this->markTestSkipped('Hangs'); - $this->row->chars = 'ab'; + $this->row->setChars('ab'); $this->row->delete(5); $this->assertEquals('ab', $this->row->chars); diff --git a/tests/TermiosTest.php b/tests/TermiosTest.php index 9f4b797..7b0d011 100644 --- a/tests/TermiosTest.php +++ b/tests/TermiosTest.php @@ -1,6 +1,6 @@ ", + "<<=", + ">>=", + "++", + "--", + "==", + "!=", + ">=", + "<=", + "&&", + "||", + "<<", + ">>", + "+=", + "-=", + "*=", + "\/=", + "%=", + "&=", + "|=", + "^=", + "->", + "::" ], "singleLineCommentStart": "\/\/", "multiLineCommentStart": "\/*", - "multiLineCommentEnd": "*\/", - "flags": 3 + "multiLineCommentEnd": "*\/" } }, "tokens": [], @@ -570,11 +620,11 @@ 4, 4, 4, + 7, 0, 0, 0, - 0, - 0, + 7, 0, 5, 5, @@ -604,7 +654,7 @@ 5, 5, 5, - 0 + 7 ], "idx": 16 }, @@ -623,12 +673,12 @@ 0, 0, 0, + 7, 0, - 0, - 5, - 5, - 5, - 0 + 13, + 13, + 13, + 7 ], "idx": 17 }, @@ -933,7 +983,7 @@ 0, 0, 0, - 0 + 7 ], "idx": 25 }, @@ -1011,7 +1061,7 @@ 0, 0, 0, - 0 + 7 ], "idx": 28 }, @@ -1089,7 +1139,7 @@ 0, 0, 0, - 0 + 7 ], "idx": 31 }, @@ -1161,15 +1211,36 @@ { "render": "{", "hl": [ - 0 + 9 ], "idx": 35 }, { "render": " \/* Input modes. *\/", "hl": [ - 0, - 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, 2, 2, 2, @@ -1213,7 +1284,7 @@ 0, 0, 0, - 0 + 7 ], "idx": 37 }, @@ -1225,8 +1296,28 @@ { "render": " \/* Output modes. *\/", "hl": [ - 0, - 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, 2, 2, 2, @@ -1271,7 +1362,7 @@ 0, 0, 0, - 0 + 7 ], "idx": 40 }, @@ -1283,8 +1374,27 @@ { "render": " \/* Control modes. *\/", "hl": [ - 0, - 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, 2, 2, 2, @@ -1330,7 +1440,7 @@ 0, 0, 0, - 0 + 7 ], "idx": 43 }, @@ -1342,8 +1452,29 @@ { "render": " \/* Local modes. *\/", "hl": [ - 0, - 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, 2, 2, 2, @@ -1387,7 +1518,7 @@ 0, 0, 0, - 0 + 7 ], "idx": 46 }, @@ -1399,8 +1530,22 @@ { "render": " \/* Control characters. *\/", "hl": [ - 0, - 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, 2, 2, 2, @@ -1444,11 +1589,11 @@ 0, 0, 0, - 0, + 9, 6, 6, - 0, - 0 + 9, + 7 ], "idx": 49 }, @@ -1460,8 +1605,13 @@ { "render": " \/* Input and output baud rates. *\/", "hl": [ - 0, - 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2, 2, 2, 2, @@ -1521,6 +1671,7 @@ 0, 0, 0, + 7, 0, 0, 0, @@ -1530,16 +1681,15 @@ 0, 0, 0, - 0, - 0 + 7 ], "idx": 52 }, { "render": "};", "hl": [ - 0, - 0 + 9, + 7 ], "idx": 53 }, @@ -1565,14 +1715,14 @@ 0, 0, 0, - 0, + 9, 4, 4, 4, 0, 0, 0, - 0, + 7, 0, 3, 3, @@ -1589,6 +1739,7 @@ 0, 0, 0, + 7, 0, 0, 0, @@ -1598,9 +1749,8 @@ 0, 0, 0, - 0, - 0, - 0 + 9, + 7 ], "idx": 55 }, @@ -1621,14 +1771,14 @@ 0, 0, 0, - 0, + 9, 4, 4, 4, 0, 0, 0, - 0, + 7, 0, 4, 4, @@ -1650,13 +1800,13 @@ 0, 0, 0, + 7, 0, - 0, - 0, - 0, - 0, - 0, - 0, + 3, + 3, + 3, + 3, + 3, 0, 3, 3, @@ -1673,6 +1823,7 @@ 0, 0, 0, + 7, 0, 0, 0, @@ -1682,9 +1833,8 @@ 0, 0, 0, - 0, - 0, - 0 + 9, + 7 ], "idx": 56 }, @@ -1906,7 +2056,7 @@ 0, 0, 0, - 0 + 9 ], "idx": 61 }, @@ -1938,7 +2088,7 @@ 0, 0, 0, - 0 + 7 ], "idx": 62 }, @@ -1970,7 +2120,7 @@ 0, 0, 0, - 0 + 7 ], "idx": 63 }, @@ -2005,7 +2155,7 @@ 0, 0, 0, - 0 + 7 ], "idx": 64 }, @@ -2040,15 +2190,15 @@ 0, 0, 0, - 0 + 7 ], "idx": 65 }, { "render": "};", "hl": [ - 0, - 0 + 9, + 7 ], "idx": 66 }, @@ -2065,22 +2215,22 @@ 0, 0, 0, + 9, + 4, + 4, + 4, + 7, 0, 4, 4, 4, - 0, - 0, - 4, - 4, - 4, + 7, 0, 0, 0, 0, - 0, - 0, - 0 + 9, + 7 ], "idx": 67 }