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

Code before:
                            }
                        }
                        ctx.set_handled();
                    }
                    LapceUICommand::ReloadBuffer(id, rev, new_content) => {
                        for (_, buffer) in data.main_split.open_files.iter_mut() {
                            if &buffer.id == id {
                                if buffer.rev + 1 == *rev {
                                    let buffer = Arc::make_mut(buffer);
                                    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();

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

Code after:
                    LapceUICommand::GotoDefinition(
                        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,
                                    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() {