mirror of https://github.com/buggins/dlangide.git
toggle line comment is working
This commit is contained in:
parent
14537d67c8
commit
0221da6a76
|
@ -124,7 +124,7 @@ class SimpleDSyntaxHighlighter : SyntaxHighlighter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool isLineComment(dstring s) {
|
protected bool isLineComment(dstring s) {
|
||||||
for (int i = 0; i < s.length - 2; i++) {
|
for (int i = 0; i < cast(int)s.length - 1; i++) {
|
||||||
if (s[i] == '/' && s[i + 1] == '/')
|
if (s[i] == '/' && s[i + 1] == '/')
|
||||||
return true;
|
return true;
|
||||||
else if (s[i] != ' ' && s[i] != '\t')
|
else if (s[i] != ' ' && s[i] != '\t')
|
||||||
|
@ -177,6 +177,26 @@ class SimpleDSyntaxHighlighter : SyntaxHighlighter {
|
||||||
return cast(dstring)res;
|
return cast(dstring)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// remove single line comment from beginning of line
|
||||||
|
protected dstring uncommentLine(dstring s) {
|
||||||
|
int p = -1;
|
||||||
|
for (int i = 0; i < cast(int)s.length - 1; i++) {
|
||||||
|
if (s[i] == '/' && s[i + 1] == '/') {
|
||||||
|
p = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (p < 0)
|
||||||
|
return s;
|
||||||
|
s = s[0..p] ~ s[p + 2 .. $];
|
||||||
|
for (int i = 0; i < s.length; i++) {
|
||||||
|
if (s[i] != ' ' && s[i] != '\t') {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// searches for neares token start before or equal to position
|
/// searches for neares token start before or equal to position
|
||||||
protected TextPosition tokenStart(TextPosition pos) {
|
protected TextPosition tokenStart(TextPosition pos) {
|
||||||
TextPosition p = pos;
|
TextPosition p = pos;
|
||||||
|
@ -301,6 +321,13 @@ class SimpleDSyntaxHighlighter : SyntaxHighlighter {
|
||||||
_content.performOperation(op, source);
|
_content.performOperation(op, source);
|
||||||
} else {
|
} else {
|
||||||
// uncomment
|
// uncomment
|
||||||
|
for (int i = 0; i < lineCount; i++) {
|
||||||
|
dsttext ~= uncommentLine(srctext[i]);
|
||||||
|
}
|
||||||
|
if (!noEolAtEndOfRange)
|
||||||
|
dsttext ~= ""d;
|
||||||
|
EditOperation op = new EditOperation(EditAction.Replace, r, dsttext);
|
||||||
|
_content.performOperation(op, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue