- local commentRegex = "^%s*" .. commentType:gsub("%*", "%*"):gsub("%-", "%-"):gsub("%.", "%."):gsub("%+", "%+"):gsub("%]", "%]"):gsub("%[", "%["):gsub("%%s", "(.*)")
+ local sel = -bp.Cursor.CurSelection
+ local curpos = -bp.Cursor.Loc
+ local index = string.find(commentType, "%%s") - 1
+ local commentedLine = commentType:gsub("%%s", trim(line))
+ bp.Buf:Replace(buffer.Loc(0, lineN), buffer.Loc(#line, lineN), util.GetLeadingWhitespace(line) .. commentedLine)
+ if bp.Cursor:HasSelection() then
+ bp.Cursor.CurSelection[1].Y = sel[1].Y
+ bp.Cursor.CurSelection[2].Y = sel[2].Y
+ bp.Cursor.CurSelection[1].X = sel[1].X
+ bp.Cursor.CurSelection[2].X = sel[2].X
+ else
+ bp.Cursor.X = curpos.X + index
+ bp.Cursor.Y = curpos.Y
+ end
+ bp.Cursor:Relocate()
+ bp.Cursor.LastVisualX = bp.Cursor:GetVisualX()
+end
+
+function uncommentLine(bp, lineN, commentRegex)
+ local line = bp.Buf:Line(lineN)
+ local commentType = bp.Buf.Settings["commenttype"]