tcd: doc, error messages

This commit is contained in:
Justin M. Keyes 2016-04-21 03:04:10 -04:00
parent ec71d87b81
commit 89e6973fe2
4 changed files with 56 additions and 68 deletions

View File

@ -1216,20 +1216,18 @@ use has("browsefilter"): >
==============================================================================
7. The current directory *current-directory*
You may use the |:cd|, |:tcd| and |:lcd| commands to change to another
directory, so you will not have to type that directory name in front of the
file names. It also makes a difference for executing external commands, e.g.
":!ls".
You can use |:cd|, |:tcd| and |:lcd| to change to another directory, so you
will not have to type that directory name in front of the file names. It also
makes a difference for executing external commands, e.g. ":!ls" or ":te ls".
There are three levels of working directories: global, tab and window. The
local working directory of the current window takes precedence over the local
working directory of the tab, which in turn takes precedence over the global
working directory. If a local working directory, tab or window, does not
exist, the next one in the hierarchy applies.
There are three current-directory "scopes": global, tab and window. The
window-local working directory takes precedence over the tab-local
working directory, which in turn takes precedence over the global
working directory. If a local working directory (tab or window) does not
exist, the next-higher scope in the hierarchy applies.
All commands for changing the working directory can be suffixed with an
exclamation mark (e.g. |:cd!|). This is for compatibility with Vim and will be
ignored by Neovim.
Commands for changing the working directory can be suffixed with a bang "!"
(e.g. |:cd!|) which is ignored, for compatibility with Vim.
*:cd* *E747* *E472*
:cd[!] On non-Unix systems: Print the current directory
@ -1254,11 +1252,10 @@ ignored by Neovim.
*:chd* *:chdir*
:chd[ir][!] [path] Same as |:cd|.
*:tc* *:tcd* *E5000* *E5001* *E5002*
*:tc* *:tcd* *E5000* *E5001* *E5002*
:tc[d][!] {path} Like |:cd|, but set the current directory for the
current tab. The current directory for other tabs
or the local directory of windows in this tab is not
changed, except for the current window.
current tab and window. The current directory for
other tabs and windows is not changed.
*:tcd-*
:tcd[!] - Change to the previous current directory (before the
@ -1284,19 +1281,20 @@ ignored by Neovim.
Also see |getcwd()|.
So long as no |:tcd| or |:lcd| command has been used, all windows share the
same current directory. Using a command to jump to another window doesn't
same "current directory". Using a command to jump to another window doesn't
change anything for the current directory.
When a |:lcd| command has been used for a window, the specified directory
becomes the current directory for that window. Windows where the |:lcd|
command has not been used stick to the tab- or global current directory. When
jumping to another window the current directory will become the last specified
local current directory. If none was specified, the tab- or global current
directory is used.
When |:lcd| has been used for a window, the specified directory becomes the
current directory for that window. Windows where the |:lcd| command has not
been used stick to the global or tab-local directory. When jumping to another
window the current directory will become the last specified local current
directory. If none was specified, the global or tab-local directory is used.
When changing tabs the same behaviour applies. If the current tab has no
local working directory the global working directory is used. When a |:cd|
command is used, the current window and tab will lose their local current
directories and will use the global current directory from now on. When a
|:tcd| command is used, only the current window will lose its local working
directories and will use the global current directory from now on. When
a |:tcd| command is used, only the current window will lose its local working
directory.
After using |:cd| the full path name will be used for reading and writing
@ -1346,9 +1344,7 @@ There are a few things to remember when editing binary files:
9. Encryption *encryption*
*:X* *E817* *E818* *E819* *E820*
Support for editing encrypted files has been removed, but may be added back in
the future. See the following discussions for more information:
Support for editing encrypted files has been removed.
https://github.com/neovim/neovim/issues/694
https://github.com/neovim/neovim/issues/701

View File

@ -1886,7 +1886,7 @@ getcmdpos() Number return cursor position in command-line
getcmdtype() String return current command-line type
getcmdwintype() String return current command-line window type
getcurpos() List position of the cursor
getcwd( [{scope}]) String the current working directory
getcwd( [{scope}]) String the current working directory
getfontname( [{name}]) String name of font being used
getfperm( {fname}) String file permissions of file {fname}
getfsize( {fname}) Number size in bytes of file {fname}
@ -3559,21 +3559,17 @@ getcurpos() Get the position of the cursor. This is like getpos('.'), but
MoveTheCursorAround
call setpos('.', save_cursor)
<
getcwd([{window}[, {tab}]]) *getcwd()*
With no argument the result is a String, which is the name of the
current effective working directory. If an arguments are provided for a
window or a tabpage the working directory of that scope is returned.
Tabs and windows are identified using their respective number. If a
number is 0 the current tab or window is implied. If one is not given
it defaults to 0. Thus
getcwd([{window}[, {tab}]]) *getcwd()*
With no arguments the result is a String, which is the name of
the current effective working directory. With {window} or
{tab} the working directory of that scope is returned.
Tabs and windows are identified by their respective numbers,
0 means current tab or window. Missing argument implies 0.
Thus the following are equivalent: >
getcwd()
getcwd(0)
getcwd(0, 0)
are all equal. If {window} is -1 it will be ignored and only the tab
will be looked at.
< If {window} is -1 it is ignored, only the tab is resolved.
getfsize({fname}) *getfsize()*
@ -3909,20 +3905,18 @@ has_key({dict}, {key}) *has_key()*
The result is a Number, which is 1 if |Dictionary| {dict} has
an entry with key {key}. Zero otherwise.
haslocaldir([{window}[, {tab}]]) *haslocaldir()*
The result is a Number, which is 1 when the specified tabpage or window
has a local path set via |:lcd| or |:tcd|, and 0 otherwise.
Tabs and windows are identified using their respective number. If a
number is 0 the current tab or window is implied. If one is not given
it defaults to 0. Thus
haslocaldir([{window}[, {tab}]]) *haslocaldir()*
The result is a Number, which is 1 when the specified tabpage
or window has a local path set via |:lcd| or |:tcd|, and
0 otherwise.
Tabs and windows are identified by their respective numbers,
0 means current tab or window. Missing argument implies 0.
Thus the following are equivalent: >
haslocaldir()
haslocaldir(0)
haslocaldir(0, 0)
are all equal. If {window} is -1 it will be ignored and only the tab
will be looked at.
< If {window} is -1 it is ignored, only the tab is resolved.
hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
The result is a Number, which is 1 if there is a mapping that

View File

@ -9826,7 +9826,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv)
}
}
// It the deepest scope number is `-1` advance the scope by one.
// If the deepest scope number is `-1` advance the scope.
if (scope_number[scope] < 0) {
scope++;
}
@ -9847,8 +9847,7 @@ static void f_getcwd(typval_T *argvars, typval_T *rettv)
win = NULL;
} else if (scope_number[kCdScopeWindow] >= 0) {
if (!tp) {
EMSG(_("E5001: A higher-level scope cannot be -1 if a lower-level"
" scope is >= 0."));
EMSG(_("E5001: Higher scope cannot be -1 if lower scope is >= 0."));
goto end;
}
@ -10782,8 +10781,7 @@ static void f_haslocaldir(typval_T *argvars, typval_T *rettv)
win = NULL;
} else if (scope_number[kCdScopeWindow] >= 0) {
if (!tp) {
EMSG(_("E5001: A higher-level scope cannot be -1 if a lower-level"
" scope is >= 0."));
EMSG(_("E5001: Higher scope cannot be -1 if lower scope is >= 0."));
return;
}

View File

@ -110,34 +110,34 @@ end
-- Test legal parameters for 'getcwd' and 'haslocaldir'
for _, cmd in ipairs {'getcwd', 'haslocaldir'} do
describe('getcwd()', function()
describe(cmd..'()', function()
-- Test invalid argument types
local expected = 'Vim(call):E474: Invalid argument'
it('fails to parse a string', function()
it('fails on string', function()
eq(expected, exc_exec('call ' .. cmd .. '("some string")'))
end)
it('fails to parse a float', function()
it('fails on float', function()
eq(expected, exc_exec('call ' .. cmd .. '(1.0)'))
end)
it('fails to parse a list', function()
it('fails on list', function()
eq(expected, exc_exec('call ' .. cmd .. '([1, 2])'))
end)
it('fails to parse a dictionary', function()
it('fails on dictionary', function()
eq(expected, exc_exec('call ' .. cmd .. '({"key": "value"})'))
end)
it('fails to parse a funcref', function()
it('fails on funcref', function()
eq(expected, exc_exec('call ' .. cmd .. '(function("tr"))'))
end)
-- Test invalid numbers
it('fails to parse number less than -1', function()
it('fails on number less than -1', function()
eq(expected, exc_exec('call ' .. cmd .. '(-2)'))
end)
local expected = 'Vim(call):E5001: A higher-level scope cannot be -1 if a lower-level scope is >= 0.'
it('fails to parse arument -1 when previous arg was greater than -1', function()
local expected = 'Vim(call):E5001: Higher scope cannot be -1 if lower scope is >= 0.'
it('fails on -1 if previous arg is >=0', function()
eq(expected, exc_exec('call ' .. cmd .. '(0, -1)'))
end)
-- Test wrong number of arguments
local expected = 'Vim(call):E118: Too many arguments for function: ' .. cmd
it('fails to parse more than one argument', function()