diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 02d96603b7..cda80dad39 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9391,9 +9391,9 @@ put_view( // Note, if a buffer for that file already exists, use :badd to // edit that buffer, to not lose folding information (:edit resets // folds in other buffers) - if (fputs("if bufexists('", fd) < 0 + if (fputs("if bufexists(\"", fd) < 0 || ses_fname(fd, wp->w_buffer, flagp, false) == FAIL - || fputs("') | buffer ", fd) < 0 + || fputs("\") | buffer ", fd) < 0 || ses_fname(fd, wp->w_buffer, flagp, false) == FAIL || fputs(" | else | edit ", fd) < 0 || ses_fname(fd, wp->w_buffer, flagp, false) == FAIL diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 9ba264deb6..c2e7bb7bf9 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -238,4 +238,18 @@ func Test_mkview_no_file_name() %bwipe endfunc +func Test_mksession_quote_in_filename() + let v:errmsg = '' + %bwipe! + split another + split x'y\"z + mksession! Xtest_mks_quoted.out + %bwipe! + source Xtest_mks_quoted.out + call assert_true(bufexists("x'y\"z")) + + %bwipe! + call delete('Xtest_mks_quoted.out') +endfunc + " vim: shiftwidth=2 sts=2 expandtab