Merge pull request #231 from jtlebi/origin/shift-tab

(de)indent behaviour enhancement
This commit is contained in:
John McLear 2011-11-28 20:23:37 -08:00
commit 9e509677dc
4 changed files with 43 additions and 16 deletions

View file

@ -3534,7 +3534,8 @@ function OUTER(gscope)
function doIndentOutdent(isOut)
{
if (!(rep.selStart && rep.selEnd))
if (!(rep.selStart && rep.selEnd) ||
((rep.selStart[0] == rep.selEnd[0]) && (rep.selStart[1] == rep.selEnd[1]) && rep.selEnd[1] > 1))
{
return false;
}
@ -3544,25 +3545,25 @@ function OUTER(gscope)
lastLine = Math.max(firstLine, rep.selEnd[0] - ((rep.selEnd[1] == 0) ? 1 : 0));
var mods = [];
var foundLists = false;
for (var n = firstLine; n <= lastLine; n++)
{
var listType = getLineListType(n);
var t = 'indent';
var level = 0;
if (listType)
{
listType = /([a-z]+)([12345678])/.exec(listType);
if (listType)
{
foundLists = true;
var t = listType[1];
var level = Number(listType[2]);
var newLevel = Math.max(1, Math.min(MAX_LIST_LEVEL, level + (isOut ? -1 : 1)));
if (level != newLevel)
{
mods.push([n, t + newLevel]);
}
t = listType[1];
level = Number(listType[2]);
}
}
var newLevel = Math.max(0, Math.min(MAX_LIST_LEVEL, level + (isOut ? -1 : 1)));
if (level != newLevel)
{
mods.push([n, (newLevel > 0) ? t + newLevel : '']);
}
}
if (mods.length > 0)
@ -3570,7 +3571,7 @@ function OUTER(gscope)
setLineListTypes(mods);
}
return foundLists;
return true;
}
editorInfo.ace_doIndentOutdent = doIndentOutdent;
@ -5231,7 +5232,8 @@ function OUTER(gscope)
var allLinesAreList = true;
for (var n = firstLine; n <= lastLine; n++)
{
if (!getLineListType(n))
var listType = getLineListType(n);
if (!listType || listType.slice(0, 'bullet'.length) != 'bullet')
{
allLinesAreList = false;
break;
@ -5241,8 +5243,16 @@ function OUTER(gscope)
var mods = [];
for (var n = firstLine; n <= lastLine; n++)
{
var t = '';
var level = 0;
var listType = /([a-z]+)([12345678])/.exec(getLineListType(n));
if (listType)
{
t = listType[1];
level = Number(listType[2]);
}
var t = getLineListType(n);
mods.push([n, allLinesAreList ? '' : (t ? t : 'bullet1')]);
mods.push([n, allLinesAreList ? 'indent' + level : (t ? 'bullet' + level : 'bullet1')]);
}
setLineListTypes(mods);
}

View file

@ -473,7 +473,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
if (tname == "ul")
{
var type;
var rr = cls && /(?:^| )list-(bullet[12345678])\b/.exec(cls);
var rr = cls && /(?:^| )list-([a-z]+[12345678])\b/.exec(cls);
type = rr && rr[1] || "bullet" + String(Math.min(_MAX_LIST_LEVEL, (state.listNesting || 0) + 1));
oldListTypeOrNull = (_enterList(state, type) || 'none');
}