Changeset 12053 in josm


Ignore:
Timestamp:
2017-05-03T18:12:48+02:00 (7 years ago)
Author:
michael2402
Message:

Fix #6447: Ensure that only move commands in same layer are combined.

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/MoveAction.java

    r12052 r12053  
    137137
    138138        ds.beginUpdate();
    139         if (c instanceof MoveCommand && ds.equals(((MoveCommand) c).getAffectedDataSet())
     139        if (c instanceof MoveCommand && ds.equals(c.getAffectedDataSet())
    140140                && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
    141141            ((MoveCommand) c).moveAgain(distx, disty);
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r12048 r12053  
    711711            return false;
    712712        }
    713         Command c = getLastCommand();
     713        Command c = getLastCommandInDataset(ds);
    714714        if (mode == Mode.MOVE) {
    715715            if (startEN == null) return false; // fix #8128
     
    784784     */
    785785    private void useLastMoveCommandIfPossible() {
    786         Command c = getLastCommand();
    787         Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(getLayerManager().getEditDataSet().getSelected());
     786        DataSet dataSet = getLayerManager().getEditDataSet();
     787        Command c = getLastCommandInDataset(dataSet);
     788        Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(dataSet.getSelected());
    788789        if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
    789790            // old command was created with different base point of movement, we need to recalculate it
     
    794795    /**
    795796     * Obtain command in undoRedo stack to "continue" when dragging
     797     * @param ds The data set the command needs to be in.
    796798     * @return last command
    797799     */
    798     private static Command getLastCommand() {
    799         Command c = !Main.main.undoRedo.commands.isEmpty()
    800                 ? Main.main.undoRedo.commands.getLast() : null;
    801         if (c instanceof SequenceCommand) {
    802             c = ((SequenceCommand) c).getLastCommand();
    803         }
    804         return c;
     800    private Command getLastCommandInDataset(DataSet ds) {
     801        LinkedList<Command> commands = Main.main.undoRedo.commands;
     802        if (!commands.isEmpty()) {
     803            Command lastCommand = commands.getLast();
     804            if (lastCommand instanceof SequenceCommand) {
     805                lastCommand = ((SequenceCommand) lastCommand).getLastCommand();
     806            }
     807            if (ds.equals(lastCommand.getAffectedDataSet())) {
     808                return lastCommand;
     809            }
     810        }
     811        return null;
    805812    }
    806813
     
    898905            Collection<OsmPrimitive> selection = ds.getSelectedNodesAndWays();
    899906            Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection);
    900             Command c = getLastCommand();
     907            Command c = getLastCommandInDataset(ds);
    901908            ds.beginUpdate();
    902             if (c instanceof MoveCommand
    903                 && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
     909            if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand) c).getParticipatingPrimitives())) {
    904910                Node selectedNode = selNodes.iterator().next();
    905911                EastNorth selectedEN = selectedNode.getEastNorth();
Note: See TracChangeset for help on using the changeset viewer.