From ed15e3e4e18312aa34bac8119c6425af5ddce79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Thu, 15 Nov 2012 04:52:22 -0300 Subject: [PATCH 1/2] Fix for issue 2110 --- src/editor/EditorCommandHandlers.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/editor/EditorCommandHandlers.js b/src/editor/EditorCommandHandlers.js index e5182ce8caf..4c7b007f20d 100644 --- a/src/editor/EditorCommandHandlers.js +++ b/src/editor/EditorCommandHandlers.js @@ -246,15 +246,24 @@ define(function (require, exports, module) { // Check if we should just do a line uncomment (if all lines in the selection are commented). if (slashComment && (ctx.token.string.match(lineExp) || endCtx.token.string.match(lineExp))) { + var ctxPos = {line: ctx.pos.line, ch: ctx.pos.ch}; + var endCtxIndex = editor.indexFromPos({line: endCtx.pos.line, ch: endCtx.token.start + endCtx.token.string.length}); + // Find if we aren't actually inside a block-comment result = true; while (result && ctx.token.string.match(lineExp)) { result = TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctx); } + // If we aren't in a block-comment. if (!result || ctx.token.className !== "comment" || ctx.token.string.match(suffixExp)) { - // We aren't in an block-comment. Find if all the lines are line-commented. - if (!_containsUncommented(editor, sel.start.line, sel.end.line)) { + // If the selection includes all the line-comments, do a block-comment + if (editor.posWithinRange(ctxPos, sel.start, sel.end) && (!endCtx.token.string.match(lineExp) + || editor.indexFromPos(sel.end) >= endCtxIndex)) { + canComment = true; + + // Find if all the lines are line-commented. + } else if (!_containsUncommented(editor, sel.start.line, sel.end.line)) { lineUncomment = true; // If can't uncomment then do nothing, since it would create an invalid comment. From e3eb88703ca5a197495d1702e8274b4ae83548ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Fri, 16 Nov 2012 15:39:35 -0300 Subject: [PATCH 2/2] Fixing if breakpoint --- src/editor/EditorCommandHandlers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/editor/EditorCommandHandlers.js b/src/editor/EditorCommandHandlers.js index 4c7b007f20d..3309220bf1e 100644 --- a/src/editor/EditorCommandHandlers.js +++ b/src/editor/EditorCommandHandlers.js @@ -258,8 +258,8 @@ define(function (require, exports, module) { // If we aren't in a block-comment. if (!result || ctx.token.className !== "comment" || ctx.token.string.match(suffixExp)) { // If the selection includes all the line-comments, do a block-comment - if (editor.posWithinRange(ctxPos, sel.start, sel.end) && (!endCtx.token.string.match(lineExp) - || editor.indexFromPos(sel.end) >= endCtxIndex)) { + if (editor.posWithinRange(ctxPos, sel.start, sel.end) && + (!endCtx.token.string.match(lineExp) || editor.indexFromPos(sel.end) >= endCtxIndex)) { canComment = true; // Find if all the lines are line-commented.