|
3110 | 3110 | // The prevInput test prevents this from firing when a context |
3111 | 3111 | // menu is closed (since the resetInput would kill the |
3112 | 3112 | // select-all detection hack) |
3113 | | - if (!cm.curOp && cm.display.prevInput != "\u200b") { |
| 3113 | + if (!cm.curOp && cm.display.selForContextMenu == cm.doc.sel) { |
3114 | 3114 | resetInput(cm); |
3115 | 3115 | if (webkit) setTimeout(bind(resetInput, cm, true), 0); // Issue #1730 |
3116 | 3116 | } |
|
3158 | 3158 | resetInput(cm); |
3159 | 3159 | // Adds "Select all" to context menu in FF |
3160 | 3160 | if (!cm.somethingSelected()) display.input.value = display.prevInput = " "; |
| 3161 | + display.selForContextMenu = cm.doc.sel; |
3161 | 3162 |
|
3162 | 3163 | // Select-all will be greyed out if there's nothing to select, so |
3163 | 3164 | // this adds a zero-width space so that we can later check whether |
3164 | 3165 | // it got selected. |
3165 | 3166 | function prepareSelectAllHack() { |
3166 | 3167 | if (display.input.selectionStart != null) { |
3167 | | - var extval = display.input.value = "\u200b" + (cm.somethingSelected() ? display.input.value : ""); |
3168 | | - display.prevInput = "\u200b"; |
| 3168 | + var selected = cm.somethingSelected(); |
| 3169 | + var extval = display.input.value = "\u200b" + (selected ? display.input.value : ""); |
| 3170 | + display.prevInput = selected ? "" : "\u200b"; |
3169 | 3171 | display.input.selectionStart = 1; display.input.selectionEnd = extval.length; |
3170 | 3172 | } |
3171 | 3173 | } |
|
3180 | 3182 | if (!ie || ie_upto8) prepareSelectAllHack(); |
3181 | 3183 | clearTimeout(detectingSelectAll); |
3182 | 3184 | var i = 0, poll = function() { |
3183 | | - if (display.prevInput == "\u200b" && display.input.selectionStart == 0) |
| 3185 | + if (display.selForContextMenu == cm.doc.sel && display.input.selectionStart == 0) |
3184 | 3186 | operation(cm, commands.selectAll)(cm); |
3185 | 3187 | else if (i++ < 10) detectingSelectAll = setTimeout(poll, 500); |
3186 | 3188 | else resetInput(cm); |
|
0 commit comments