Skip to content

Commit

Permalink
WIP: Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
magicant committed Apr 16, 2024
1 parent d671f05 commit 8d6f2c7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,20 @@ inputresult_T input_interactive(struct xwcsbuf_T *buf, void *inputinfo)

// FIXME

wchar_t *line;
#if YASH_ENABLE_HISTORY
size_t oldbuflen = buf->length;
#endif
inputresult_T result;

#if YASH_ENABLE_LINEEDIT
/* read a line using line editing */
if (info->fileinfo->fd == STDIN_FILENO
&& shopt_lineedit != SHOPT_NOLINEEDIT) {
wchar_t *line;
result = le_readline(prompt, true, &line);
switch (result) {
case INPUT_OK:
wb_catfree(buf, line);
goto success;
case INPUT_EOF:
case INPUT_INTERRUPTED:
Expand All @@ -279,10 +283,7 @@ inputresult_T input_interactive(struct xwcsbuf_T *buf, void *inputinfo)
print_prompt(prompt.main);
print_prompt(prompt.styler);

xwcsbuf_T linebuf;
wb_init(&linebuf);
result = input_file(&linebuf, info->fileinfo);
line = wb_towcs(&linebuf);
result = input_file(buf, info->fileinfo);

print_prompt(PROMPT_RESET);

Expand All @@ -292,9 +293,8 @@ inputresult_T input_interactive(struct xwcsbuf_T *buf, void *inputinfo)
if (info->prompttype == 1)
info->prompttype = 2;
#if YASH_ENABLE_HISTORY
add_history(line);
add_history(&buf->contents[oldbuflen]);
#endif
wb_catfree(buf, line);
#if YASH_ENABLE_LINEEDIT
done:
#endif
Expand Down

0 comments on commit 8d6f2c7

Please sign in to comment.