mirror of https://github.com/lapce/lapce.git
Limit search response size (#1753)
This commit is contained in:
parent
9a45b602bc
commit
3130a9c377
|
@ -16,6 +16,7 @@
|
|||
### Bug Fixes
|
||||
- [#1737](https://github.com/lapce/lapce/pull/1726): Fix an issue that plugins can't be upgraded
|
||||
- [#1724](https://github.com/lapce/lapce/pull/1724): files and hidden folders no longer will be considered when trying to open a plugin base folder
|
||||
- [#1753](https://github.com/lapce/lapce/pull/1753): Limit proxy search response size in order to avoid issues with absurdly long lines
|
||||
|
||||
## 0.2.4
|
||||
|
||||
|
|
|
@ -304,6 +304,7 @@ fn handle_request(&mut self, id: RequestId, rpc: ProxyRequest) {
|
|||
} => {
|
||||
let workspace = self.workspace.clone();
|
||||
let proxy_rpc = self.proxy_rpc.clone();
|
||||
// Perform the search on another thread to avoid blocking the proxy thread
|
||||
thread::spawn(move || {
|
||||
let result = if let Some(workspace) = workspace.as_ref() {
|
||||
let mut matches = IndexMap::new();
|
||||
|
@ -325,10 +326,20 @@ fn handle_request(&mut self, id: RequestId, rpc: ProxyRequest) {
|
|||
let mymatch = matcher
|
||||
.find(line.as_bytes())?
|
||||
.unwrap();
|
||||
// Shorten the line to avoid sending over absurdly long-lines
|
||||
// (such as in minified javascript)
|
||||
// Note that the start/end are column based, not absolute from the
|
||||
// start of the file.
|
||||
let display_range = mymatch
|
||||
.start()
|
||||
.saturating_sub(100)
|
||||
..line
|
||||
.len()
|
||||
.min(mymatch.end() + 100);
|
||||
line_matches.push((
|
||||
lnum as usize,
|
||||
(mymatch.start(), mymatch.end()),
|
||||
line.to_string(),
|
||||
line[display_range].to_string(),
|
||||
));
|
||||
Ok(true)
|
||||
}),
|
||||
|
|
Loading…
Reference in New Issue