From 79db0d8abb95b0a266f42f755d6c6f9afbe9e570 Mon Sep 17 00:00:00 2001
From: Georg Ringer <georg.ringer@gmail.com>
Date: Wed, 18 Mar 2020 14:15:37 +0100
Subject: [PATCH] [BUGFIX] Respect dots in TS keys during autocomplete

The code completion must differ between dots at the end and those in the
middle which belong to the key.

Instead of just replacing all dots, only the one at the end is used to
split the TS into chunks.

Resolves: #84534
Releases: master, 9.5
Change-Id: I82890b56d1a95584ddc079cc7e9c930cfaa71830
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63765
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog <look@susi.dev>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Susanne Moog <look@susi.dev>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 .../Classes/Controller/CodeCompletionController.php      | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/typo3/sysext/t3editor/Classes/Controller/CodeCompletionController.php b/typo3/sysext/t3editor/Classes/Controller/CodeCompletionController.php
index c1e1b6e0a47a..6098f928bdeb 100644
--- a/typo3/sysext/t3editor/Classes/Controller/CodeCompletionController.php
+++ b/typo3/sysext/t3editor/Classes/Controller/CodeCompletionController.php
@@ -86,9 +86,8 @@ class CodeCompletionController
     {
         $cleanedTreeBranch = [];
         foreach ($treeBranch as $key => $value) {
-            $dotCount = substr_count($key, '.');
             //type definition or value-assignment
-            if ($dotCount === 0) {
+            if (substr($key, -1) !== '.') {
                 if ($value != '') {
                     if (mb_strlen($value) > 20) {
                         $value = mb_substr($value, 0, 20);
@@ -98,11 +97,13 @@ class CodeCompletionController
                     }
                     $cleanedTreeBranch[$key]['v'] = $value;
                 }
-            } elseif ($dotCount == 1) {
+            } else {
                 // subtree (definition of properties)
                 $subBranch = $this->treeWalkCleanup($value);
                 if ($subBranch) {
-                    $key = str_replace('.', '', $key);
+                    if (substr($key, -1) === '.') {
+                        $key = rtrim($key, '.');
+                    }
                     if (!isset($cleanedTreeBranch[$key])) {
                         $cleanedTreeBranch[$key] = [];
                     }
-- 
GitLab