Skip to content

Commit 641f985

Browse files
committed
refactor(compiler): adjust overlap and text length validation #257
- Change `OVERLAP` from 5 to 4 for better context handling. - Update text length validation to require more than 4 characters. - Use `OVERLAP` constant in `search` method for consistency. - Improve command documentation format in `DevInsDocumentationProvider`.
1 parent 02f4293 commit 641f985

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/LocalSearchInsCommand.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import com.intellij.openapi.vfs.VirtualFile
2020
*/
2121
class LocalSearchInsCommand(val myProject: Project, private val scope: String, val text: String?) : InsCommand {
2222
private val MAX_LINE_SIZE = 180
23-
private val OVERLAP = 5
23+
private val OVERLAP = 4
2424

2525
override suspend fun execute(): String {
2626
val text = (text ?: scope).trim()
2727
/// check text length if less then 3 return alert slowly
2828
if (text.length < 3) {
29-
throw IllegalArgumentException("Text length should be more than 5")
29+
throw IllegalArgumentException("Text length should be more than 4")
3030
}
3131

3232
val textSearch = search(myProject, text, OVERLAP)
@@ -49,7 +49,7 @@ class LocalSearchInsCommand(val myProject: Project, private val scope: String, v
4949
* the lines of context around the keyword in that file. The context includes the matched line and the specified
5050
* number of lines before and after it.
5151
*/
52-
private fun search(project: Project, keyword: String, overlap: Int = 5): Map<VirtualFile, List<String>> {
52+
private fun search(project: Project, keyword: String, overlap: Int = OVERLAP): Map<VirtualFile, List<String>> {
5353
val result = mutableMapOf<VirtualFile, List<String>>()
5454

5555
ProjectFileIndex.getInstance(project).iterateContent { file ->

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/documentation/DevInsDocumentationProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class DevInsDocumentationProvider : AbstractDocumentationProvider() {
5555
fun allCommands(): List<String> {
5656
return BuiltinCommand.all().map {
5757
val example = BuiltinCommand.example(it)
58-
"${it.commandName}: ${it.description}\nExample:\n```$example\n```"
58+
"name: /${it.commandName}:\ndesc: ${it.description}\nExample:\n```devin\n$example\n```"
5959
}
6060
}
6161
}

0 commit comments

Comments
 (0)