aboutsummaryrefslogtreecommitdiffstats
path: root/src/i_insert.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/i_insert.go')
-rw-r--r--src/i_insert.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/i_insert.go b/src/i_insert.go
index ce08ebc..0bb55a8 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -138,9 +138,15 @@ func i_insert_host(data *HardData, insert *HostNode) {
if len(insert.Drive) == 0 {
insert.Drive = nil
}
- filename := i_insert_format_filename(insert.Name,
- data.data_dir + insert.parent.path())
- insert.filename = filename
+ filename := insert.filename
+ replace := false
+ if len(filename) == 0 || data.yank != nil {
+ filename = i_insert_format_filename(insert.Name,
+ data.data_dir + insert.parent.path())
+ insert.filename = filename
+ } else {
+ replace = true
+ }
fmt, err := yaml.Marshal(insert)
if err != nil {
c_error_mode("yaml", err, &data.ui)
@@ -154,6 +160,14 @@ func i_insert_host(data *HardData, insert *HostNode) {
data.insert = nil
return
}
+ if replace == true && data.litems.curr != nil {
+ tmp := e_deep_copy_host(data.insert)
+ data.litems.curr.Host = &tmp
+ data.litems.reset_id()
+ data.ui.mode = NORMAL_MODE
+ data.insert = nil
+ return
+ }
// HACK: not sure if this is necessary
// if data.litems.curr.is_dir() == true {
// data.litems.curr.Dirs.lhost.add_back(insert)