Opened 3 years ago
Last modified 7 months ago
#22423 reopened defect
[Patch] Do not mix capital/lowerkey letter keys in Tags/Memberships window
Reported by: | nkamapper | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core | Version: | |
Keywords: | sort keys Tags/memberships panel | Cc: |
Description
In the Tags/Memberships window keys are by default sorted with capital letter keys first, then lowerkey letter keys. If I accidentially hit the column header then the keys are sorted with capital and lowerkey letter keys mixed. I have not found a way to reverse that mistake, except restarting JOSM.
Keys in capital letter are usually temporary keys used when importing, so it is very inconvenient to have them mixed with the "permitted" keys. It increases the risk of forgetting to delete a capital letter key before uploading.
The sorting could be improved by sorting capital letter keys and lowerkey letter keys separately, as per the default sorting, or at least support a way to get back to that state.
Attachments (1)
Change History (13)
comment:1 by , 3 years ago
comment:2 by , 2 years ago
Type: | enhancement → defect |
---|
It would be very helpful to have this fixed. It is one of the few cases were I often have to exit and restart JOSM.
The simple solution is to always sort capital letter keys first/last, as per the current initial state.
comment:4 by , 15 months ago
Cannot reproduce the problem with latest, probably because of changes in r18973, but since unit tests fail this might change again.
comment:5 by , 15 months ago
Even if I do revert r18973, I think this is fixable -- I just have to change Collator.SECONDARY
to Collator.TERTIARY
. But that may have an effect on other users of AlphanumComparator
, so I'll have to do a look-through to see what is affected.
When I originally did the change in r18973, I assumed (wrongly) that String#compareTo
and Collator#compare
were semantically the same for ASCII characters. I think I can work around that by having an array with mappings. I'm not a fan, but it is a hot path.
EDIT: NVM. It will be a bit more complex; the default sorting rules for the collator are aAbBcC
.
comment:6 by , 14 months ago
Milestone: | → 24.02 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:7 by , 14 months ago
Keywords: | sort keys Tags/memberships panel added |
---|---|
Milestone: | 24.02 |
Resolution: | fixed |
Status: | closed → reopened |
Does not work for me. Still the same problem on startup the order of the keys is first all keys with a capital letter as first letter and then all keys with a small letter as first letter both "groups" sorted from A-Z resp. a-z. Clicking on "Key" sorts in alphabetical order from bottom to top but with in "group" with each capital letter just above its small equivalent. With another click the latter order is reversed (alphabetical order from bottom to top) with each capital letter just above its small equivalent, again. Further clicking just leads to the last two orders but the sorting with two "groups" (first all capital and then all small letters) is unavailable.
Relative:URL: ^/trunk Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b Last:Changed Date: 2024-03-08 13:22:01 +0100 (Fri, 08 Mar 2024) Revision:19015 Build-Date:2024-03-09 02:30:59 URL:https://josm.openstreetmap.de/svn/trunk Identification: JOSM/1.5 (19015 en) Linux Debian GNU/Linux 12 (bookworm) Memory Usage: 279 MB / 1970 MB (85 MB allocated, but free) Java version: 17.0.10+7-Debian-1deb12u1, Debian, OpenJDK 64-Bit Server VM Look and Feel: javax.swing.plaf.metal.MetalLookAndFeel Environment variable LANG: en_US.UTF-8 System property file.encoding: UTF-8 System property sun.jnu.encoding: UTF-8 Locale info: en_US Numbers with default locale: 1234567890 -> 1234567890 Desktop environment: GNOME
comment:8 by , 14 months ago
OK, seems I didn't understand the wanted behaviour. Now I can reproduce. I'll try to find out where the initial order is created. It seems not to depend on the order in the *.osm file, changing it there has no effect.
follow-up: 12 comment:9 by , 14 months ago
Hm, the initial order is sorted in a TreeMap
(field valueCount
in class PropertiesDialog
). This sorts the keys using String.compare()
, while the dialog sorts them with AlphanumComparator
.
I see two possibe fixes:
1) always use String.compare()
for the keys (also in the dialog)
2) add a preference to allow a choice which comparator should be used.
The patch for 1) is very simple:
-
src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
C:\josm\core>svn diff src\org\openstreetmap\josm\gui\dialogs\properties\PropertiesDialog.java
353 353 final RemoveHiddenSelection removeHiddenSelection = new RemoveHiddenSelection(); 354 354 tagTable.getSelectionModel().addListSelectionListener(removeHiddenSelection); 355 355 tagRowSorter.addRowSorterListener(removeHiddenSelection); 356 tagRowSorter.setComparator(0, AlphanumComparator.getInstance());356 tagRowSorter.setComparator(0, (o1, o2) -> ((String) o1).compareTo((String) o2)); 357 357 tagRowSorter.setComparator(1, (o1, o2) -> { 358 358 if (o1 instanceof Map && o2 instanceof Map) { 359 359 final String v1 = ((Map) o1).size() == 1 ? (String) ((Map) o1).keySet().iterator().next() : KeyedItem.DIFFERENT_I18N;
In my eyes this is enough, I see no reason to use the complex sorting for the keys as they are expected to be plain ascii.
comment:10 by , 14 months ago
Summary: | Do not mix capital/lowerkey letter keys in Tags/Memberships window → [Patch] Do not mix capital/lowerkey letter keys in Tags/Memberships window |
---|
comment:11 by , 7 months ago
It sure would be cool to get this problem fixed :)
I still need to restart JOSM frequently because uppercase/lowercase keys are mixed.
comment:12 by , 7 months ago
Replying to GerdP:
they are expected to be plain ascii.
Erm, for the most part, but isn't OSM fully supports UTF-8? Sure keys should be ASCII, but you never know :)
+1,
an additional sort option to get back to capital letters on top, would be nice.