SelectComment
This commit is contained in:
@@ -226,4 +226,33 @@ void CheckKeybindingColission() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Range EncloseScope(Buffer *buffer, Int pos_min, Int pos_max, String16 open, String16 close) {
|
||||
Range result = {pos_min, pos_max};
|
||||
String16 buffer_string = GetString(buffer);
|
||||
for (Int i = pos_min - 1; i >= 0; i -= 1) {
|
||||
String16 string = Skip(buffer_string, i);
|
||||
if (StartsWith(string, open)) {
|
||||
result.min = i + open.len;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (Int i = pos_max; i < buffer->len; i += 1) {
|
||||
String16 string = Skip(buffer_string, i);
|
||||
if (StartsWith(string, close)) {
|
||||
result.max = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CMD_SelectComment() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
For (active.view->carets) {
|
||||
Range scope = EncloseScope(active.buffer, it.range.min, it.range.max, u"/*", u"*/");
|
||||
it.range = scope;
|
||||
}
|
||||
|
||||
} RegisterCommand(CMD_SelectComment, "ctrl-shift-l", "Find /* and */ and select the content in between");
|
||||
Reference in New Issue
Block a user