mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-15 06:44:10 +02:00
CommentLines improvements
This commit is contained in:
parent
4c421033ab
commit
688d1f8dd1
1 changed files with 31 additions and 19 deletions
|
@ -2265,7 +2265,7 @@ namespace IDE.ui
|
||||||
int maxPos = mSelection.GetValueOrDefault().MaxPos;
|
int maxPos = mSelection.GetValueOrDefault().MaxPos;
|
||||||
mSelection = null;
|
mSelection = null;
|
||||||
|
|
||||||
while (minPos >= 0)
|
while (minPos > 0)
|
||||||
{
|
{
|
||||||
var c = mData.mText[minPos - 1].mChar;
|
var c = mData.mText[minPos - 1].mChar;
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
|
@ -2279,7 +2279,35 @@ namespace IDE.ui
|
||||||
|
|
||||||
for (int i = minPos; i < maxPos; i++)
|
for (int i = minPos; i < maxPos; i++)
|
||||||
{
|
{
|
||||||
bool isSpace = false;
|
var c = mData.mText[i].mChar;
|
||||||
|
if (didLineComment)
|
||||||
|
{
|
||||||
|
if (c == '\n')
|
||||||
|
{
|
||||||
|
didLineComment = false;
|
||||||
|
lineStartCol = 0;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (c == '\t')
|
||||||
|
lineStartCol += 4;
|
||||||
|
else if (c == ' ')
|
||||||
|
lineStartCol++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wantLineCol == -1)
|
||||||
|
wantLineCol = lineStartCol;
|
||||||
|
else
|
||||||
|
wantLineCol = Math.Min(wantLineCol, lineStartCol);
|
||||||
|
didLineComment = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wantLineCol = Math.Max(0, wantLineCol);
|
||||||
|
|
||||||
|
didLineComment = false;
|
||||||
|
lineStartCol = 0;
|
||||||
|
for (int i = minPos; i < maxPos; i++)
|
||||||
|
{
|
||||||
var c = mData.mText[i].mChar;
|
var c = mData.mText[i].mChar;
|
||||||
if (didLineComment)
|
if (didLineComment)
|
||||||
{
|
{
|
||||||
|
@ -2296,27 +2324,11 @@ namespace IDE.ui
|
||||||
commentNow = true;
|
commentNow = true;
|
||||||
|
|
||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
{
|
|
||||||
lineStartCol += 4;
|
lineStartCol += 4;
|
||||||
isSpace = true;
|
|
||||||
}
|
|
||||||
else if (c == ' ')
|
else if (c == ' ')
|
||||||
{
|
|
||||||
lineStartCol++;
|
lineStartCol++;
|
||||||
isSpace = true;
|
else
|
||||||
}
|
|
||||||
|
|
||||||
if (!isSpace)
|
|
||||||
{
|
|
||||||
if (c == '\n')
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
commentNow = true;
|
commentNow = true;
|
||||||
if (wantLineCol == -1)
|
|
||||||
wantLineCol = lineStartCol;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (commentNow)
|
if (commentNow)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue