Repository: lapce/lapce
File: lapce-ui/src/tab.rs (Rust)

Code before:
                                    buffer.load_content(new_content);
                                    buffer.rev = *rev;

                                    for (_, editor) in
                                        data.main_split.editors.iter_mut()
                                    {
                                        if editor.content == buffer.content
                                            && editor.cursor.offset() >= buffer.len()
                                        {
                                            let editor = Arc::make_mut(editor);
                                            let new_position =
                                                buffer.len().saturating_sub(1);
                                            if data.config.lapce.modal {
                                                editor.cursor =
                                                    movement::Cursor::new(
                                                        CursorMode::Normal(
                                                            new_position,
                                                        ),
                                                        None,
                                                    );
                                            } else {
                                                editor.cursor =
                                                    movement::Cursor::new(
                                                        CursorMode::Insert(
                                                            Selection::caret(
                                                                new_position,
                                                            ),
                                                        ),
                                                        None,
                                                    );
                                            }
                                        }
                                    }
                                }
                                break;
                            }
                        }
                        ctx.set_handled();
                    }
                    LapceUICommand::UpdateSemanticStyles(_id, path, rev, styles) => {
                        let buffer =
                            data.main_split.open_files.get_mut(path).unwrap();
                        if buffer.rev == *rev {
                            let buffer = Arc::make_mut(buffer);
                            buffer.semantic_styles = Some(styles.clone());
                            buffer.line_styles.borrow_mut().clear();
                        }
                        ctx.set_handled();
                    }
                    LapceUICommand::ShowCodeActions
                    | LapceUICommand::CancelCodeActions => {

Review comment (suggestion):
use this ```buffer.offset_line_end(buffer.len(), true)```

Code after:
                                data.main_split.jump_to_location(
                                    ctx,
                                    None,
                                    location.clone(),
                                    &data.config,
                                );
                            }
                        }
                        ctx.set_handled();
                    }
                    LapceUICommand::GotoReference(
                        editor_view_id,
                        offset,
                        location,
                    ) => {
                        if let Some(editor) = data.main_split.active_editor() {
                            if *editor_view_id == editor.view_id
                                && *offset == editor.cursor.offset()
                            {
                                data.main_split.jump_to_location(
                                    ctx,
                                    Some(*editor_view_id),
                                    location.clone(),
                                    &data.config,
                                );
                            }
                        }
                        ctx.set_handled();
                    }
                    LapceUICommand::UpdateCodeActions(path, rev, offset, resp) => {
                        if let Some(buffer) =
                            data.main_split.open_files.get_mut(path)
                        {
                            if buffer.rev == *rev {
                                Arc::make_mut(buffer)
                                    .code_actions
                                    .insert(*offset, resp.clone());
                            }
                        }
                    }
                    LapceUICommand::PaletteReferences(offset, locations) => {
                        if let Some(editor) = data.main_split.active_editor() {
                            if *offset == editor.cursor.offset() {
                                let locations = locations
                                    .iter()
                                    .map(|l| EditorLocationNew {
                                        path: PathBuf::from(l.uri.path()),
                                        position: Some(l.range.start),
                                        scroll_offset: None,
                                        hisotry: None,
                                    })