fix:尝试处理粘贴一个路径时,导致的提示卡顿问题。
This commit is contained in:
parent
2501ef76bc
commit
27241c505b
@ -497,6 +497,10 @@ char* fc_readline()
|
|||||||
++len;
|
++len;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool need_predic = true;
|
||||||
|
std::chrono::time_point<std::chrono::high_resolution_clock> p1, p2;
|
||||||
|
p1 = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
word.clear();
|
word.clear();
|
||||||
clear_line();
|
clear_line();
|
||||||
@ -521,10 +525,19 @@ char* fc_readline()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
set_cursor_x(cur_pos + 1);
|
set_cursor_x(cur_pos + 1);
|
||||||
|
need_predic = true;
|
||||||
|
|
||||||
// Read character from console
|
// Read character from console
|
||||||
int ch = _getch();
|
int ch = _getch();
|
||||||
|
|
||||||
|
p2 = p1;
|
||||||
|
p1 = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
|
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(p1 - p2).count();
|
||||||
|
if (duration <= 10) {
|
||||||
|
need_predic = false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case ENTER:
|
case ENTER:
|
||||||
append_his(main_buf);
|
append_his(main_buf);
|
||||||
@ -624,7 +637,12 @@ char* fc_readline()
|
|||||||
}
|
}
|
||||||
// 补正
|
// 补正
|
||||||
trans2buf(tmp_buf);
|
trans2buf(tmp_buf);
|
||||||
str_predict = file_predict(tmp_buf);
|
if (need_predic) {
|
||||||
|
str_predict = file_predict(tmp_buf);
|
||||||
|
} else if (!str_predict.empty()) {
|
||||||
|
str_predict.clear();
|
||||||
|
}
|
||||||
|
p1 = std::chrono::high_resolution_clock::now();
|
||||||
}
|
}
|
||||||
return main_buf;
|
return main_buf;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user