jigish / slate

A window management application (replacement for Divvy/SizeUp/ShiftIt)
GNU General Public License v3.0
7.84k stars 512 forks source link

Snapshot operations (js config) do not respect the set name attribute (version 1.0.25) #278

Open henrikolsen opened 11 years ago

henrikolsen commented 11 years ago

It seems the name "name" is used, no matter what I try to set it to.

Using the code below.

var snapshotTest = slate.operation("snapshot", {
  "name" : "mySnapshotTest",
  "save" : true
});
slate.bind("b:ctrl;shift;alt;cmd", snapshotTest);

var deleteSnapshot = slate.operation("delete-snapshot", {
  "name" : "nonMatchingSnapshotName",
  "all" : true
});
slate.bind("m:ctrl;shift;alt;cmd", deleteSnapshot);

Looking at the snapshot file on disk, I see the following.

Before snapshot:

{
  "menuSnapshot": {
    "save-to-disk": true,
    "snapshots": [
      {
        "apps": {
          "Safari": [
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            },
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            }
          ],
          "Sublime Text 2": [
            {
              "y": 22,
              "height": 1028,
              "title": "snapshots",
              "app-name": "Sublime Text 2",
              "x": 4,
              "width": 1676
            }
          ],
          "iTerm": [
            {
              "y": 22,
              "height": 1006,
              "title": "2. vim",
              "app-name": "iTerm",
              "x": 842,
              "width": 838
            }
          ]
        }
      }
    ],
    "name": "menuSnapshot",
    "stack": false
  }
}

After snapshot (notice name is "name", not "mySnapshotTest"):

{
  "menuSnapshot": {
    "save-to-disk": true,
    "snapshots": [
      {
        "apps": {
          "Safari": [
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            },
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            }
          ],
          "Sublime Text 2": [
            {
              "y": 22,
              "height": 1028,
              "title": "snapshots",
              "app-name": "Sublime Text 2",
              "x": 4,
              "width": 1676
            }
          ],
          "iTerm": [
            {
              "y": 22,
              "height": 1006,
              "title": "2. vim",
              "app-name": "iTerm",
              "x": 842,
              "width": 838
            }
          ]
        }
      }
    ],
    "name": "menuSnapshot",
    "stack": false
  },
  "_internal_UndoSnapshot": {
    "save-to-disk": true,
    "snapshots": [
      {
        "apps": {
          "iTerm": [
            {
              "y": 22,
              "height": 1006,
              "title": "2. vim",
              "app-name": "iTerm",
              "x": 842,
              "width": 838
            }
          ],
          "Sublime Text 2": [
            {
              "y": 22,
              "height": 1028,
              "title": "snapshots",
              "app-name": "Sublime Text 2",
              "x": 4,
              "width": 1676
            }
          ],
          "Safari": [
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            },
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            }
          ]
        }
      }
    ],
    "name": "_internal_UndoSnapshot",
    "stack": true
  },
  "name": {
    "save-to-disk": true,
    "snapshots": [
      {
        "apps": {
          "iTerm": [
            {
              "y": 22,
              "height": 1006,
              "title": "2. vim",
              "app-name": "iTerm",
              "x": 842,
              "width": 838
            }
          ],
          "Sublime Text 2": [
            {
              "y": 22,
              "height": 1028,
              "title": "snapshots",
              "app-name": "Sublime Text 2",
              "x": 4,
              "width": 1676
            }
          ],
          "Safari": [
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            },
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            }
          ]
        }
      }
    ],
    "name": "name",
    "stack": false
  }
}

Deleting snapshot, but using a non matching name (indicating code doesn't care and still used "name"):

{
  "menuSnapshot": {
    "save-to-disk": true,
    "snapshots": [
      {
        "apps": {
          "Safari": [
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            },
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            }
          ],
          "Sublime Text 2": [
            {
              "y": 22,
              "height": 1028,
              "title": "snapshots",
              "app-name": "Sublime Text 2",
              "x": 4,
              "width": 1676
            }
          ],
          "iTerm": [
            {
              "y": 22,
              "height": 1006,
              "title": "2. vim",
              "app-name": "iTerm",
              "x": 842,
              "width": 838
            }
          ]
        }
      }
    ],
    "name": "menuSnapshot",
    "stack": false
  },
  "_internal_UndoSnapshot": {
    "save-to-disk": true,
    "snapshots": [
      {
        "apps": {
          "iTerm": [
            {
              "y": 22,
              "height": 1006,
              "title": "2. vim",
              "app-name": "iTerm",
              "x": 842,
              "width": 838
            }
          ],
          "Sublime Text 2": [
            {
              "y": 22,
              "height": 1028,
              "title": "snapshots",
              "app-name": "Sublime Text 2",
              "x": 4,
              "width": 1676
            }
          ],
          "Safari": [
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            },
            {
              "y": 22,
              "height": 1028,
              "title": "Untitled",
              "app-name": "Safari",
              "x": 4,
              "width": 1676
            }
          ]
        }
      }
    ],
    "name": "_internal_UndoSnapshot",
    "stack": true
  }
}
bbreukelen commented 8 years ago

Running into the same issue. The name of the snapshot is always defined as "name" : "name". Any change this can be fixed? Thanks a lot!