Ticket #4673: 4673.patch
File 4673.patch, 2.7 KB (added by , 15 years ago) |
---|
-
_source/plugins/undo/plugin.js
179 179 this.reset(); 180 180 } 181 181 182 183 var editingKeyCodes = { /*Backspace*/ 8:1, /*Delete*/ 46:1, /*Space*/ 32:1 , /*Tab*/ 9:1 }, 184 modifierKeyCodes = { /*Shift*/ 16:1, /*Ctrl*/ 17:1, /*Alt*/ 18:1 }, 185 navigationKeyCodes = { 37:1, 38:1, 39:1, 40:1 }; // Arrows: L, T, R, B 186 182 187 UndoManager.prototype = 183 188 { 184 189 /** … … 187 192 */ 188 193 type : function( event ) 189 194 { 190 var keystroke = event && event.data.getKeystroke(), 191 192 // Backspace, Delete 193 modifierCodes = { 8:1, 46:1 }, 194 // Keystrokes which will modify the contents. 195 isModifier = keystroke in modifierCodes, 196 wasModifier = this.lastKeystroke in modifierCodes, 197 lastWasSameModifier = isModifier && keystroke == this.lastKeystroke, 198 199 // Arrows: L, T, R, B 200 resetTypingCodes = { 37:1, 38:1, 39:1, 40:1 }, 195 var keystroke = event && event.data.getKey(), 196 isModifierKey = keystroke in modifierKeyCodes, 197 isEditingKey = keystroke in editingKeyCodes, 198 wasEditingKey = this.lastKeystroke in editingKeyCodes, 199 sameAsLastEditingKey = isEditingKey && keystroke == this.lastKeystroke, 201 200 // Keystrokes which navigation through contents. 202 isReset = keystroke in resetTypingCodes,203 wasReset = this.lastKeystroke in resetTypingCodes,201 isReset = keystroke in navigationKeyCodes, 202 wasReset = this.lastKeystroke in navigationKeyCodes, 204 203 205 204 // Keystrokes which just introduce new contents. 206 isContent = ( !is Modifier&& !isReset ),205 isContent = ( !isEditingKey && !isReset ), 207 206 208 207 // Create undo snap for every different modifier key. 209 modifierSnapshot = ( is Modifier && !lastWasSameModifier),208 modifierSnapshot = ( isEditingKey && !sameAsLastEditingKey ), 210 209 // Create undo snap on the following cases: 211 // 1. Just start to type .210 // 1. Just start to type . 212 211 // 2. Typing some content after a modifier. 213 212 // 3. Typing some content after make a visible selection. 214 startedTyping = ! this.typing215 || ( isContent && ( was Modifier|| wasReset ) );213 startedTyping = !( isModifierKey || this.typing ) 214 || ( isContent && ( wasEditingKey || wasReset ) ); 216 215 217 216 if ( startedTyping || modifierSnapshot ) 218 217 { … … 250 249 } 251 250 252 251 this.lastKeystroke = keystroke; 252 253 // Ignore modifier keys. (#4673) 254 if( isModifierKey ) 255 return; 253 256 // Create undo snap after typed too much (over 25 times). 254 if ( is Modifier)257 if ( isEditingKey ) 255 258 { 256 259 this.typesCount = 0; 257 260 this.modifiersCount++;