﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5876	"[PATCH] AutoCompletingComboBox gets initialized with wrong value for ""key:subkey"" key elements in custom presets.xml"	ax	team	"EDIT: please see [ticket:5876#comment:7 comment #7] for how to reliably reproduce this bug. the original description below might be misleading.

----

how to reproduce:

in a data layer that has has both ""key"" and ""key:subkey"" elements, eg. elements tagged with ""source=bing"" as well as elements tagged with ""!source:population=psgc"", if you try editing ""source=bing"" in the properties panel by double-clicking or pressing ""edit"", the key will be initialized with the wrong value ""!source:population=psgc"". even if you only change the value and don't touch the key, the key will be changed nevertheless because it is wrongly initialized!

cause:

[source:/josm/trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java@3479#L50 AutoCompletingComboBox::insertString(..., ""source"", ...)] calls [source:/josm/trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java@3479#L116 AutoCompletingComboBox::lookupItem(""source"")]. This method [source:/josm/trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java@3479#L119 loops through all existing keys in the current layer and returns a key that '''starts with''' ""source""]. as ""source"" is before ""!source:population"" in the list being iterated over, bestItem is first set to the correct value ""source"", but in the next iteration overwritten with the wrong value ""!source:population"". this wrong key is then inserted into the combobox.

solution:

i'm not familiar with the autocomplete code. on a first glance, i don't understand why AutoCompletingComboBox::insertString() needs a fuzzy startsWith to insert a discret item. but there might be a reason behind this. which is why i leave the fix to this issue to someone who knows :)
"	defect	closed	normal		Core		fixed		
