language: Make Buffer::new take an explicit ID (#2900)

See Linear description for the full explanation of the issue. This PR is
mostly a mechanical change, except for the one case where we do pass in
an explicit `next_id` instead of `model_id` in project.rs.

Release Notes:
- Fixed a bug where some results were not reported in project search in
presence of unnamed buffers.
This commit is contained in:
Piotr Osiewicz 2023-08-28 11:51:50 +02:00 committed by GitHub
parent 81a5043b61
commit 07b9c6c302
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 141 additions and 104 deletions

View file

@ -176,7 +176,9 @@ impl LogStore {
cx.notify();
LanguageServerState {
rpc_state: None,
log_buffer: cx.add_model(|cx| Buffer::new(0, "", cx)).clone(),
log_buffer: cx
.add_model(|cx| Buffer::new(0, cx.model_id() as u64, ""))
.clone(),
}
})
.log_buffer
@ -241,7 +243,7 @@ impl LogStore {
let rpc_state = server_state.rpc_state.get_or_insert_with(|| {
let io_tx = self.io_tx.clone();
let language = project.read(cx).languages().language_for_name("JSON");
let buffer = cx.add_model(|cx| Buffer::new(0, "", cx));
let buffer = cx.add_model(|cx| Buffer::new(0, cx.model_id() as u64, ""));
cx.spawn_weak({
let buffer = buffer.clone();
|_, mut cx| async move {
@ -327,7 +329,7 @@ impl LspLogView {
.projects
.get(&project.downgrade())
.and_then(|project| project.servers.keys().copied().next());
let buffer = cx.add_model(|cx| Buffer::new(0, "", cx));
let buffer = cx.add_model(|cx| Buffer::new(0, cx.model_id() as u64, ""));
let mut this = Self {
editor: Self::editor_for_buffer(project.clone(), buffer, cx),
project,