1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Tentative: Remove conditional from wrap-selection text-operation (#3749)

As per the discussion in #3749, the original purpose of the removed condition is unknown, and so we cannot be certain that removing it is safe, but doing so seems the best way of discovering more...
This commit is contained in:
Simon Huber 2019-02-05 18:18:20 +01:00 committed by Jeremy Ruston
parent e5f3301c1c
commit 5e9fc661a9

View File

@ -16,14 +16,12 @@ exports["wrap-selection"] = function(event,operation) {
if(operation.selStart === operation.selEnd) {
// No selection; check if we're within the prefix/suffix
if(operation.text.substring(operation.selStart - event.paramObject.prefix.length,operation.selStart + event.paramObject.suffix.length) === event.paramObject.prefix + event.paramObject.suffix) {
// Remove the prefix and suffix unless they comprise the entire text
if(operation.selStart > event.paramObject.prefix.length || (operation.selEnd + event.paramObject.suffix.length) < operation.text.length ) {
operation.cutStart = operation.selStart - event.paramObject.prefix.length;
operation.cutEnd = operation.selEnd + event.paramObject.suffix.length;
operation.replacement = "";
operation.newSelStart = operation.cutStart;
operation.newSelEnd = operation.newSelStart;
}
// Remove the prefix and suffix
operation.cutStart = operation.selStart - event.paramObject.prefix.length;
operation.cutEnd = operation.selEnd + event.paramObject.suffix.length;
operation.replacement = "";
operation.newSelStart = operation.cutStart;
operation.newSelEnd = operation.newSelStart;
} else {
// Wrap the cursor instead
operation.cutStart = operation.selStart;