From cbff2fb6921ef3873d5d903067bf9164af2adb54 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Thu, 11 Jun 2020 12:45:47 +0200 Subject: [PATCH] Fix e.toggleComment being undefined in CM sublime keymap (#4662) * Create comment.js * Update tiddlywiki.files --- .../files/addons/comment/comment.js | 4 ++++ .../codemirror-keymap-sublime-text/files/tiddlywiki.files | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 plugins/tiddlywiki/codemirror-keymap-sublime-text/files/addons/comment/comment.js diff --git a/plugins/tiddlywiki/codemirror-keymap-sublime-text/files/addons/comment/comment.js b/plugins/tiddlywiki/codemirror-keymap-sublime-text/files/addons/comment/comment.js new file mode 100644 index 000000000..57775035f --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-sublime-text/files/addons/comment/comment.js @@ -0,0 +1,4 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var y={},E=/[^\s\u00a0]/,M=e.Pos;function s(e){var n=e.search(E);return-1==n?0:n}function S(e,n){var t=e.getMode();return!1!==t.useInnerComments&&t.innerMode?e.getModeAt(n):t}e.commands.toggleComment=function(e){e.toggleComment()},e.defineExtension("toggleComment",function(e){e=e||y;for(var n=this,t=1/0,i=this.listSelections(),l=null,o=i.length-1;0<=o;o--){var r=i[o].from(),m=i[o].to();r.line>=t||(m.line>=t&&(m=M(t,0)),t=r.line,null==l?l=n.uncomment(r,m,e)?"un":(n.lineComment(r,m,e),"line"):"un"==l?n.uncomment(r,m,e):n.lineComment(r,m,e))}}),e.defineExtension("lineComment",function(o,e,r){r=r||y;var n,t,m,a,c,g,f=this,i=S(f,o),l=f.getLine(o.line);null!=l&&(n=o,t=l,!/\bstring\b/.test(f.getTokenTypeAt(M(n.line,0)))||/^[\'\"\`]/.test(t))&&((m=r.lineComment||i.lineComment)?(a=Math.min(0!=e.ch||e.line==o.line?e.line+1:e.line,f.lastLine()+1),c=null==r.padding?" ":r.padding,g=r.commentBlankLines||o.line==e.line,f.operation(function(){if(r.indent){for(var e=null,n=o.line;nt.length)&&(e=t)}for(n=o.line;nr||a.operation(function(){if(0!=o.fullLines){var e=E.test(a.getLine(r));a.replaceRange(m+f,M(r)),a.replaceRange(g+m,M(i.line,0));var n=o.blockCommentLead||c.blockCommentLead;if(null!=n)for(var t=i.line+1;t<=r;++t)t==r&&!e||a.replaceRange(n+m,M(t,0))}else a.replaceRange(f,l),a.replaceRange(g,i)})):(o.lineComment||c.lineComment)&&0!=o.fullLines&&a.lineComment(i,l,o)}),e.defineExtension("uncomment",function(e,n,t){t=t||y;var l,o=this,i=S(o,e),r=Math.min(0!=n.ch||n.line==e.line?n.line:n.line-1,o.lastLine()),m=Math.min(e.line,r),a=t.lineComment||i.lineComment,c=[],g=null==t.padding?" ":t.padding;e:if(a){for(var f=m;f<=r;++f){var s=o.getLine(f),d=s.indexOf(a);if(-1