@@ -26,9 +26,6 @@ import cc.unitmesh.devins.completion.CompletionContext
2626import cc.unitmesh.devins.completion.CompletionTriggerType
2727import kotlinx.coroutines.launch
2828
29- /* *
30- * 补全弹窗组件
31- */
3229@Composable
3330fun CompletionPopup (
3431 items : List <CompletionItem >,
@@ -47,7 +44,6 @@ fun CompletionPopup(
4744 val listState = rememberLazyListState()
4845 val scope = rememberCoroutineScope()
4946
50- // 当选中项改变时,滚动到可见区域
5147 LaunchedEffect (selectedIndex) {
5248 if (selectedIndex in items.indices) {
5349 scope.launch {
@@ -96,9 +92,6 @@ fun CompletionPopup(
9692 }
9793}
9894
99- /* *
100- * 单个补全项行
101- */
10295@Composable
10396private fun CompletionItemRow (
10497 item : CompletionItem ,
@@ -121,7 +114,6 @@ private fun CompletionItemRow(
121114 .padding(horizontal = 12 .dp, vertical = 6 .dp),
122115 verticalAlignment = Alignment .CenterVertically
123116 ) {
124- // 图标(emoji)
125117 item.icon?.let { icon ->
126118 Text (
127119 text = icon,
@@ -130,9 +122,7 @@ private fun CompletionItemRow(
130122 )
131123 }
132124
133- // 主要内容
134125 Column (modifier = Modifier .weight(1f )) {
135- // 显示文本
136126 Text (
137127 text = item.displayText,
138128 style = MaterialTheme .typography.bodyMedium.copy(
@@ -144,7 +134,6 @@ private fun CompletionItemRow(
144134 overflow = androidx.compose.ui.text.style.TextOverflow .Ellipsis
145135 )
146136
147- // 描述文本
148137 item.description?.let { description ->
149138 Text (
150139 text = description,
@@ -158,7 +147,6 @@ private fun CompletionItemRow(
158147 }
159148 }
160149
161- // 右侧信息(如文件扩展名)
162150 if (item.description != " Directory" ) {
163151 val fileExtension = item.text.substringAfterLast(' .' , " " )
164152 if (fileExtension.isNotEmpty() && fileExtension.length <= 4 ) {
@@ -179,9 +167,6 @@ private fun CompletionItemRow(
179167 }
180168}
181169
182- /* *
183- * 补全触发器 - 检测是否应该触发补全
184- */
185170object CompletionTrigger {
186171 fun shouldTrigger (char : Char ): Boolean {
187172 return char in setOf (' @' , ' /' , ' $' , ' :' , ' `' )
@@ -203,7 +188,6 @@ object CompletionTrigger {
203188 cursorPosition : Int ,
204189 triggerType : CompletionTriggerType
205190 ): CompletionContext ? {
206- // 找到最近的触发字符
207191 val triggerChar = when (triggerType) {
208192 CompletionTriggerType .AGENT -> ' @'
209193 CompletionTriggerType .COMMAND -> ' /'
@@ -215,10 +199,8 @@ object CompletionTrigger {
215199 val triggerOffset = fullText.lastIndexOf(triggerChar, cursorPosition - 1 )
216200 if (triggerOffset < 0 ) return null
217201
218- // 提取查询文本(触发字符后到光标的文本)
219202 val queryText = fullText.substring(triggerOffset + 1 , cursorPosition)
220-
221- // 检查查询文本是否有效(不包含空白字符或换行)
203+
222204 if (queryText.contains(' \n ' ) || queryText.contains(' ' )) {
223205 return null
224206 }
0 commit comments