Skip to content

Commit 4bc2a7e

Browse files
JimZhouZZYda-liii
authored andcommitted
!460 [201_4] 修复 custom-complete 时删除掉前缀补全框不关闭
1 parent 39e79c2 commit 4bc2a7e

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

devel/201_4.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@
5757
流程同generic-edit环境的版本,只是第三步改为
5858
3. 插入一段Python块,输入内容(例如re)。
5959

60+
## 2025/07/29 fix: custom-complete时删除掉前缀补全框不关闭
61+
### What
62+
修改了custom-complete对于prefix定义的条件,使用一个辅助变量prefix_initialized来判断是否定义,而不是使用prefix自身。
63+
64+
### Why
65+
补全项的第一项(补全中使用到的prefix)也可能是空字符串“”,这种情况发生时,如果使用`prefix != ""`来判断prefix是否初始化就不正确了。
66+
67+
### 如何测试
68+
这块bug fix比较小,不写在上面的流程中了。
69+
0. 确保 Completion style 设置为 Popup
70+
1. 插入一个Scheme块
71+
2. 插入一些可以补全的字符,例如"(a"
72+
3. 按tab补全
73+
4. 删除掉前缀,在这个例子里是"a"
74+
5. 检查:补全框因前缀为空而消失
75+
76+
6077
## 2025/07/18 令Popup补全模式下不显示消息
6178
### What
6279
移除了Popup补全模式下显示消息的代码。

src/Edit/Interface/edit_complete.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,26 @@ edit_interface_rep::custom_complete (tree r) {
338338
int i, r_N= N (r);
339339
int min_compls_N= 1;
340340
string prefix;
341+
bool prefix_initialized= false;
341342
hashset<string> compls;
342343
if (completion_style == string ("Popup")) {
343344
min_compls_N= 2; // 至少需要2个补全结果(前缀自身和一个补全结果)
344345
compls << string (""); // 在补全结果中插入一个空值以保留前缀自身
345346
}
346-
for (i= 0; i < r_N; i++)
347+
for (i= 0; i < r_N; i++) {
347348
if (is_atomic (r[i])) {
348349
string l= r[i]->label;
349350
if (is_quoted (l)) l= scm_unquote (l);
350-
if (prefix == "") prefix= l;
351-
else compls << l;
351+
if (!prefix_initialized) {
352+
// 这里使用补全的第一个结果(自身)定义了 prefix
353+
// 第一个结果可能为空,所以不能使用 prefix = "" 来判断
354+
// 需要一个另外的辅助变量
355+
prefix = l;
356+
prefix_initialized= true;
357+
}
358+
compls << l;
352359
}
360+
}
353361
// cout << prefix << ", " << compls << LF;
354362
if ((prefix == "") || (N (compls) < min_compls_N)) {
355363
set_input_normal ();

0 commit comments

Comments
 (0)