Modify

Opened 4 years ago

Closed 2 years ago

Last modified 2 years ago

#21324 closed defect (fixed)

[PATCH] Command stack says "pasting 1 tag to [number] objects" regardless of how many tags are pasted

Reported by: tguen Owned by: team
Priority: minor Milestone: 22.12
Component: Core Version: tested
Keywords: command stack paste Cc:

Description (last modified by tguen)

What steps will reproduce the problem?

  1. Copy multiple tags
  2. Select an object
  3. ctrl+v

What is the expected result?

Command stack section of sidebar should correctly count the number of tags being pasted

What happens instead?

It always says "pasting 1 tag"

Please provide any additional information below. Attach a screenshot if possible.

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2021-08-02 19:44:04 +0200 (Mon, 02 Aug 2021)
Revision:18118
Build-Date:2021-08-02 18:26:20
URL:https://josm.openstreetmap.de/svn/trunk

Identification: JOSM/1.5 (18118 en) Linux Arch Linux
Memory Usage: 320 MB / 3984 MB (96 MB allocated, but free)
Java version: 16.0.2+7, N/A, OpenJDK 64-Bit Server VM
Look and Feel: com.formdev.flatlaf.FlatDarkLaf
Screen: :0.0 2560×1440 (scaling 1.00×1.00)
Maximum Screen Size: 2560×1440
Best cursor sizes: 16×16→16×16, 32×32→32×32
Environment variable LANG: en_US.UTF-8
System property file.encoding: ANSI_X3.4-1968
System property sun.jnu.encoding: ANSI_X3.4-1968
Locale info: en_US
Numbers with default locale: 1234567890 -> 1234567890
Desktop environment: KDE
VM arguments: [-Djosm.restart=true, -Dawt.useSystemAAFontSettings=on]
Program arguments: [/aux/osm/portland.jos]
Dataset consistency test: No problems found

Plugins:
+ apache-commons (35524)
+ apache-http (35589)
+ buildings_tools (35756)
+ ejml (35458)
+ flatlaf (35799)
+ geotools (35458)
+ jaxb (35543)
+ jna (35662)
+ jts (35458)
+ mapwithai (1.8.4)
+ opendata (35803)
+ reverter (35732)
+ terracer (35640)
+ undelete (35640)
+ utilsplugin2 (35792)

Map paint styles:
- https://josm.openstreetmap.de/josmfile?page=Styles/Admin_Boundaries&zip=1
+ https://josm.openstreetmap.de/josmfile?page=Styles/iD&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Lane_and_Road_Attributes&zip=1
+ https://josm.openstreetmap.de/josmfile?page=Styles/MapWithAI&zip=1

Last errors/warnings:
- 00006.260 E: Failed to locate image 'MapWithAI'
- 00008.586 E: Unsupported savable layer type: TMSLayer
- 00008.606 E: Unsupported savable layer type: TMSLayer
- 00008.612 E: Unsupported savable layer type: TMSLayer

Attachments (0)

Change History (8)

comment:1 by tguen, 4 years ago

Description: modified (diff)

comment:2 by skyper, 4 years ago

Ok, I can reproduce, if I:

  • copy multiple tags in Properties/Memberships panel
  • select an new object without tags
  • paste (Ctrl+V)

If I use "paste tags" (Ctrl+Shift+V) it works as expected.

comment:3 by skyper, 4 years ago

Keywords: command stack paste added
Priority: trivialminor
Version: latest

comment:4 by skyper, 4 years ago

Version: latesttested

Actually, it depends from where the tags are copied.

  • If copied from mapview and "Paste Tags" is used everything is fine with the correct number of tags and each listed individually
  • If copied from Tags/Memberships panel both action "Paste" and "Paste Tags" display the wrong number of tags and the tags are not listed but the lower level once unfolded does only have one entry with the correct numbers.

Best would be if in both cases lead to the identical outcome.
I went back til r15810 without any change of behavior.

comment:5 by taylor.smock, 2 years ago

Milestone: 22.12
Summary: Command stack says "pasting 1 tag to [number] objects" regardless of how many tags are pasted[PATCH] Command stack says "pasting 1 tag to [number] objects" regardless of how many tags are pasted

Once I actually debugged this, it was fairly simple. We are just counting the commands that are done, and one code path makes one command per tag while the other makes one command for all the tags.

I don't know why one of the code paths is making one command per tag. The revision log wasn't very helpful. :(

  • src/org/openstreetmap/josm/gui/datatransfer/importers/AbstractTagPaster.java

    diff --git a/src/org/openstreetmap/josm/gui/datatransfer/importers/AbstractTagPaster.java b/src/org/openstreetmap/josm/gui/datatransfer/importers/AbstractTagPaster.java
    a b  
    2222import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2323import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2424import org.openstreetmap.josm.tools.I18n;
     25import org.openstreetmap.josm.tools.Utils;
    2526
    2627/**
    2728 * This transfer support allows us to transfer tags to the selected primitives
     
    6162     */
    6263    protected static void commitCommands(Collection<? extends OsmPrimitive> selection, List<Command> commands) {
    6364        if (!commands.isEmpty()) {
    64             String title1 = trn("Pasting {0} tag", "Pasting {0} tags", commands.size(), commands.size());
     65            int changedTags = Utils.filteredCollection(commands, ChangePropertyCommand.class).stream().mapToInt(p -> p.getTags().size()).sum();
     66            changedTags = changedTags > 0 ? changedTags : commands.size();
     67            String title1 = trn("Pasting {0} tag", "Pasting {0} tags", changedTags, changedTags);
    6568            String title2 = trn("to {0} object", "to {0} objects", selection.size(), selection.size());
    6669            @I18n.QuirkyPluralString
    6770            final String title = title1 + ' ' + title2;

comment:6 by taylor.smock, 2 years ago

Resolution: fixed
Status: newclosed

In 18610/josm:

Fix #21324: Command stack says "pasting 1 tag to [number] objects" regardless of how many tags are pasted

comment:7 by taylor.smock, 2 years ago

Milestone: 22.1222.11

comment:8 by taylor.smock, 2 years ago

Milestone: 22.1122.12

Milestone renamed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.