Skip to content

Commit 76dfa0e

Browse files
committed
Revert "WIP: Refactor"
This reverts commit 8d6f2c7.
1 parent 2ebed7d commit 76dfa0e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

input.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -254,20 +254,16 @@ inputresult_T input_interactive(struct xwcsbuf_T *buf, void *inputinfo)
254254

255255
// FIXME
256256

257-
#if YASH_ENABLE_HISTORY
258-
size_t oldbuflen = buf->length;
259-
#endif
257+
wchar_t *line;
260258
inputresult_T result;
261259

262260
#if YASH_ENABLE_LINEEDIT
263261
/* read a line using line editing */
264262
if (info->fileinfo->fd == STDIN_FILENO
265263
&& shopt_lineedit != SHOPT_NOLINEEDIT) {
266-
wchar_t *line;
267264
result = le_readline(prompt, true, &line);
268265
switch (result) {
269266
case INPUT_OK:
270-
wb_catfree(buf, line);
271267
goto success;
272268
case INPUT_EOF:
273269
case INPUT_INTERRUPTED:
@@ -282,7 +278,10 @@ inputresult_T input_interactive(struct xwcsbuf_T *buf, void *inputinfo)
282278
print_prompt(prompt.main);
283279
print_prompt(prompt.styler);
284280

285-
result = input_file(buf, info->fileinfo);
281+
xwcsbuf_T linebuf;
282+
wb_init(&linebuf);
283+
result = input_file(&linebuf, info->fileinfo);
284+
line = wb_towcs(&linebuf);
286285

287286
print_prompt(PROMPT_RESET);
288287

@@ -292,8 +291,9 @@ inputresult_T input_interactive(struct xwcsbuf_T *buf, void *inputinfo)
292291
if (info->prompttype == 1)
293292
info->prompttype = 2;
294293
#if YASH_ENABLE_HISTORY
295-
add_history(&buf->contents[oldbuflen]);
294+
add_history(line);
296295
#endif
296+
wb_catfree(buf, line);
297297
#if YASH_ENABLE_LINEEDIT
298298
done:
299299
#endif

0 commit comments

Comments
 (0)