first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -3,12 +3,27 @@
|
||||
//! These functions are used by both the `CommentListView` (in the code review panel)
|
||||
//! and the blocklist's imported comments rendering.
|
||||
|
||||
use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
|
||||
use chrono::{Duration, Local};
|
||||
use pathfinder_color::ColorU;
|
||||
use galaxy_core::ui::theme::color::internal_colors::{neutral_1, neutral_2, text_sub};
|
||||
use galaxy_core::ui::theme::Fill;
|
||||
use warp_editor::content::buffer::InitialBufferState;
|
||||
use warp_editor::render::element::VerticalExpansionBehavior;
|
||||
use warpui::elements::new_scrollable::ScrollableAppearance;
|
||||
use warpui::elements::{
|
||||
Border, ChildView, Container, CornerRadius, CrossAxisAlignment, Flex, Hoverable,
|
||||
MainAxisAlignment, MainAxisSize, MouseStateHandle, ParentElement, Radius, ScrollbarWidth,
|
||||
Shrinkable, Text,
|
||||
};
|
||||
use warpui::platform::Cursor;
|
||||
use warpui::text_layout::ClipConfig;
|
||||
use warpui::units::Pixels;
|
||||
use warpui::{AppContext, Element, EventContext, SingletonEntity, View, ViewContext, ViewHandle};
|
||||
|
||||
use crate::appearance::Appearance;
|
||||
use crate::code::buffer_location::LocalOrRemotePath;
|
||||
use crate::code::editor::comment_editor::create_readonly_comment_markdown_editor;
|
||||
use crate::code::editor::view::{CodeEditorRenderOptions, CodeEditorView};
|
||||
use crate::code_review::comments::{
|
||||
@@ -17,21 +32,6 @@ use crate::code_review::comments::{
|
||||
use crate::editor::InteractionState;
|
||||
use crate::notebooks::editor::view::RichTextEditorView;
|
||||
use crate::util::time_format::human_readable_approx_duration;
|
||||
use galaxy_core::ui::theme::color::internal_colors::{neutral_1, neutral_2, text_sub};
|
||||
use galaxy_core::ui::theme::Fill;
|
||||
use galaxy_editor::content::buffer::InitialBufferState;
|
||||
use galaxy_editor::render::element::VerticalExpansionBehavior;
|
||||
use galaxyui::elements::new_scrollable::ScrollableAppearance;
|
||||
use galaxyui::elements::ScrollbarWidth;
|
||||
use galaxyui::elements::{
|
||||
Border, ChildView, Container, CornerRadius, CrossAxisAlignment, Flex, Hoverable,
|
||||
MainAxisAlignment, MainAxisSize, MouseStateHandle, ParentElement, Radius, Shrinkable, Text,
|
||||
};
|
||||
use galaxyui::platform::Cursor;
|
||||
use galaxyui::text_layout::ClipConfig;
|
||||
use galaxyui::units::Pixels;
|
||||
use galaxyui::{AppContext, Element, EventContext, SingletonEntity, View, ViewContext, ViewHandle};
|
||||
use pathfinder_color::ColorU;
|
||||
|
||||
/// Configuration for making the comment header clickable.
|
||||
pub(crate) struct HeaderClickHandler {
|
||||
@@ -229,7 +229,7 @@ fn render_comment_text_section(
|
||||
/// highlighting is set based on the file path.
|
||||
fn create_static_diff_content_editor<V: View>(
|
||||
content: &LineDiffContent,
|
||||
file_path: &Path,
|
||||
file_path: Option<&LocalOrRemotePath>,
|
||||
ctx: &mut ViewContext<V>,
|
||||
) -> ViewHandle<CodeEditorView> {
|
||||
let editor = ctx.add_typed_action_view(|ctx| {
|
||||
@@ -252,7 +252,10 @@ fn create_static_diff_content_editor<V: View>(
|
||||
let original_text = content.original_text();
|
||||
let state = InitialBufferState::plain_text(original_text.trim());
|
||||
view.reset(state, ctx);
|
||||
view.set_language_with_path(file_path, ctx);
|
||||
if let Some(file_path) = file_path {
|
||||
let language_path = file_path.path_component();
|
||||
view.set_language_with_path(&language_path, ctx);
|
||||
}
|
||||
});
|
||||
editor
|
||||
}
|
||||
@@ -299,7 +302,7 @@ impl CommentViewCard {
|
||||
always_use_static_diff: bool,
|
||||
disable_scrolling: bool,
|
||||
max_width: Option<Pixels>,
|
||||
repo_path: Option<&Path>,
|
||||
repo_path: Option<&LocalOrRemotePath>,
|
||||
ctx: &mut ViewContext<V>,
|
||||
) -> Self {
|
||||
let comment_editor = create_readonly_comment_markdown_editor(
|
||||
@@ -334,7 +337,8 @@ impl CommentViewCard {
|
||||
{
|
||||
if always_use_static_diff || comment.outdated {
|
||||
Some(CommentDiffContent::StaticEditor(
|
||||
create_static_diff_content_editor(content, absolute_file_path, ctx),
|
||||
// Language detection only needs the path component (extension).
|
||||
create_static_diff_content_editor(content, Some(absolute_file_path), ctx),
|
||||
))
|
||||
} else {
|
||||
Some(CommentDiffContent::EditorLens)
|
||||
@@ -356,7 +360,7 @@ impl CommentViewCard {
|
||||
pub(crate) fn update_source<V: View>(
|
||||
&mut self,
|
||||
new_source: AttachedReviewComment,
|
||||
repo_path: Option<&Path>,
|
||||
repo_path: Option<&LocalOrRemotePath>,
|
||||
ctx: &mut ViewContext<V>,
|
||||
) {
|
||||
self.comment_editor.update(ctx, |editor, ctx| {
|
||||
@@ -449,23 +453,19 @@ impl CommentViewCard {
|
||||
matches!(self.diff_content, Some(CommentDiffContent::EditorLens))
|
||||
}
|
||||
|
||||
/// Recomputes the cached display title.
|
||||
pub(crate) fn update_title(&mut self, repo_path: Option<&Path>) {
|
||||
self.title = Self::compute_title(&self.source, repo_path);
|
||||
}
|
||||
|
||||
/// Refreshes the cached `last_updated_duration` to the current time.
|
||||
pub(crate) fn refresh_last_updated_duration(&mut self) {
|
||||
self.last_updated_duration = Local::now() - self.source.last_update_time;
|
||||
}
|
||||
|
||||
fn compute_title(source: &AttachedReviewComment, repo_path: Option<&Path>) -> String {
|
||||
fn compute_title(
|
||||
source: &AttachedReviewComment,
|
||||
repo_path: Option<&LocalOrRemotePath>,
|
||||
) -> String {
|
||||
let file_path = source.target.absolute_file_path().map(|p| {
|
||||
repo_path
|
||||
.and_then(|rp| p.strip_prefix(rp).ok())
|
||||
.unwrap_or(p)
|
||||
.display()
|
||||
.to_string()
|
||||
.and_then(|rp| rp.strip_repo_prefix(p))
|
||||
.unwrap_or_else(|| p.display_path())
|
||||
});
|
||||
let line_number = source.target.line_number().map(|lc| lc.as_u32() + 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user