aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/fs.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-02-02 21:17:37 +0800
committerGitHub <noreply@github.com>2024-02-02 21:17:37 +0800
commite98decf9a68e41b09214aa60b77d0db29b7d648a (patch)
tree6a0a47d9f59209b1230637a55b10f25bb72c71d6 /src/nvim/os/fs.c
parent1bf645918e94e7e8f770592484164f1ee303f24e (diff)
downloadrneovim-e98decf9a68e41b09214aa60b77d0db29b7d648a.tar.gz
rneovim-e98decf9a68e41b09214aa60b77d0db29b7d648a.tar.bz2
rneovim-e98decf9a68e41b09214aa60b77d0db29b7d648a.zip
feat(quickfix): support -q - to read 'errorfile' from stdin (#27303)
Note that this only works when stdin is a pipe.
Diffstat (limited to 'src/nvim/os/fs.c')
-rw-r--r--src/nvim/os/fs.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index d80539708d..566d51f30a 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -55,6 +55,7 @@
#ifdef MSWIN
# include "nvim/mbyte.h"
# include "nvim/option.h"
+# include "nvim/os/os_win_console.h"
# include "nvim/strings.h"
#endif
@@ -541,6 +542,22 @@ os_dup_dup:
return ret;
}
+/// Open the file descriptor for stdin.
+int os_open_stdin_fd(void)
+{
+ int stdin_dup_fd;
+ if (stdin_fd > 0) {
+ stdin_dup_fd = stdin_fd;
+ } else {
+ stdin_dup_fd = os_dup(STDIN_FILENO);
+#ifdef MSWIN
+ // Replace the original stdin with the console input handle.
+ os_replace_stdin_to_conin();
+#endif
+ }
+ return stdin_dup_fd;
+}
+
/// Read from a file
///
/// Handles EINTR and ENOMEM, but not other errors.