Skip to content

Commit

Permalink
textReplace bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
bugluo committed Sep 27, 2017
1 parent 58a394f commit 7d5df57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions WeSketch.sketchplugin/Contents/Sketch/textReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function textReplace(context) {
};

function createUserInterface() {
if (selection && selection.count() == 1 && selection[0].class() == MSTextLayer) {
if (selection.length>0 && selection.count() == 1 && selection[0].class() == MSTextLayer) {
if (selection[0].editingDelegate()) {
var range = selection[0].editingDelegate().textView().selectedRange();
var value = selection[0].stringValue();
Expand Down Expand Up @@ -103,7 +103,7 @@ function textReplace(context) {
switch ([layer class]) {
case MSTextLayer:
if ([layer stringValue].trim().match(textToFind)) {
if (selection[0].editingDelegate() && layer.objectID() == selection[0].objectID()) {
if (selection.length>0 && selection[0].editingDelegate() && layer.objectID() == selection[0].objectID()) {
var value = layer.stringValue();
var result = value.replace(textToFind, textToReplace);
var valueLength = value.length();
Expand Down

0 comments on commit 7d5df57

Please sign in to comment.