fortrangoingonforty/fgof-lineedit / 22ababa

Browse files

Honor forced history

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
22ababad36dd766ef3d58661066a7765ebdb6bf3
Parents
4593e16
Tree
c11bb1e

1 changed file

StatusFile+-
M src/fgof_lineedit.f90 12 1
src/fgof_lineedit.f90modified
@@ -105,6 +105,9 @@ contains
105105
     character(len=:), allocatable, intent(out) :: line
106106
     logical, intent(in), optional :: store_history
107107
     logical :: should_store
108
+    type(history_entry), allocatable :: new_history(:)
109
+    integer :: count
110
+    integer :: i
108111
 
109112
     call normalize_lineedit(editor)
110113
     line = editor%buffer
@@ -115,7 +118,15 @@ contains
115118
       should_store = len_trim(line) > 0
116119
     end if
117120
 
118
-    if (should_store) call add_history_entry(editor, line)
121
+    if (should_store) then
122
+      count = history_count(editor)
123
+      allocate(new_history(count + 1))
124
+      do i = 1, count
125
+        new_history(i)%text = editor%history(i)%text
126
+      end do
127
+      new_history(count + 1)%text = line
128
+      call move_alloc(new_history, editor%history)
129
+    end if
119130
 
120131
     editor%buffer = ""
121132
     editor%cursor = 1