mirror of https://github.com/lapce/lapce.git
Add ability to open file/file diff from source control context menu (#1590)
* open file/diff from source control context menu * update changelog * use matches macro
This commit is contained in:
parent
dad6a58c50
commit
c53d8509d1
|
@ -4,8 +4,9 @@
|
|||
|
||||
### Features/Changes
|
||||
|
||||
- [#1590](https://github.com/lapce/lapce/pull/1590): Added ability to open file and file diff from source control context menu
|
||||
- [#1570](https://github.com/lapce/lapce/pull/1570): Added a basic tab context menu with common close actions
|
||||
- [#1560](https://github.com/lapce/lapce/pull/1560): Added ability to copy active editor remote file path to clipboard.
|
||||
- [#1560](https://github.com/lapce/lapce/pull/1560): Added ability to copy active editor remote file path to clipboard
|
||||
- [#1510](https://github.com/lapce/lapce/1510): Added support to discard changes to a file
|
||||
- [#1459](https://github.com/lapce/lapce/pull/1459): Implement icon theme system
|
||||
- **This is a breaking change for colour themes!**
|
||||
|
|
|
@ -182,10 +182,46 @@ fn event(
|
|||
let source_control = data.source_control.clone();
|
||||
let target_file_diff =
|
||||
source_control.file_diffs[target_line].0.clone();
|
||||
let target_file_path = target_file_diff.path().clone();
|
||||
|
||||
let mut menu = druid::Menu::<LapceData>::new("");
|
||||
let item = druid::MenuItem::new("Discard Changes")
|
||||
let mut item = druid::MenuItem::new("Open Changes").command(
|
||||
Command::new(
|
||||
LAPCE_UI_COMMAND,
|
||||
LapceUICommand::OpenFileDiff(
|
||||
source_control.file_diffs[target_line]
|
||||
.0
|
||||
.path()
|
||||
.clone(),
|
||||
"head".to_string(),
|
||||
),
|
||||
Target::Auto,
|
||||
),
|
||||
);
|
||||
|
||||
menu = menu.entry(item);
|
||||
|
||||
let enable_open_file =
|
||||
!matches!(target_file_diff, FileDiff::Deleted(_));
|
||||
|
||||
item = druid::MenuItem::new("Open File")
|
||||
.enabled(enable_open_file)
|
||||
.on_activate(move |ctx, _, _| {
|
||||
ctx.submit_command(Command::new(
|
||||
LAPCE_UI_COMMAND,
|
||||
LapceUICommand::OpenFile(
|
||||
target_file_path.clone(),
|
||||
true,
|
||||
),
|
||||
Target::Auto,
|
||||
));
|
||||
});
|
||||
|
||||
menu = menu.entry(item);
|
||||
|
||||
menu = menu.separator();
|
||||
|
||||
item = druid::MenuItem::new("Discard Changes")
|
||||
.on_activate(move |ctx, _, _| {
|
||||
ctx.submit_command(Command::new(
|
||||
LAPCE_COMMAND,
|
||||
|
@ -193,7 +229,7 @@ fn event(
|
|||
kind: CommandKind::Workbench(
|
||||
LapceWorkbenchCommand::SourceControlDiscardTargetFileChanges
|
||||
),
|
||||
data: Some(serde_json::json!(target_file_diff))
|
||||
data: Some(serde_json::json!(target_file_diff.clone()))
|
||||
},
|
||||
Target::Auto,
|
||||
));
|
||||
|
|
Loading…
Reference in New Issue