Correct Fold behavior and update roadmap (#524)

* Correct Fold behavior and update roadmap

* Use abstract class

* update markdown table
This commit is contained in:
Peng Lyu 2016-07-29 15:43:42 +08:00 committed by Grant Mathews
parent 8150c0b180
commit 6a87d15960
2 changed files with 120 additions and 40 deletions

View File

@ -417,3 +417,82 @@ Status | Command | Description
:white_check_mark: | :tabm[ove] [N] | Move the current tab page to after tab page N.
:x: | :tabs | List the tab pages and the windows they contain.
| :tabd[o] {cmd} | Execute {cmd} in each tab page.
## options
### Commands
Status | Command | Description
---|--------|------------------------------
| :se[t] | show all modified options
| :se[t] all | show all non-termcap options
| :se[t] termcap | show all termcap options
:white_check_mark: | :se[t] {option} | set boolean option (switch it on), show string or number option
:white_check_mark: | :se[t] no{option} | reset boolean option (switch it off)
| :se[t] inv{option} |invert boolean option
:white_check_mark: | :se[t] {option}={value} | set string/number option to {value}
| :se[t] {option}+={value} | append {value} to string option, add {value} to number option
| :se[t] {option}-={value} | remove {value} to string option, subtract {value} from number option
| :se[t] {option}? | show value of {option}
| :se[t] {option}& | reset {option} to its default value
| :setl[ocal] | like ":set" but set the local value for options that have one
| :setg[lobal] | like ":set" but set the global value of a local option
| :fix[del] | set value of 't_kD' according to value of 't_kb'
| :opt[ions] | open a new window to view and set options, grouped by functionality, a one line explanation and links to the help
### Option list
Since the list is too long, now we just put those already supported options here.
Status | Command | Default Value | Description
---|--------|-------|------------------------------
:white_check_mark:| tabstop (ts) | 4. we use Code's default value `tabSize` instead of Vim | number of spaces that <Tab> in file uses
:white_check_mark:| expandtab (et) | True. we use Code's default value `inserSpaces` instead of Vim | use spaces when <Tab> is inserted
## Folding
### Fold methods
The folding method can be set with the 'foldmethod' option. This is currently not possible as we are relying on Code's Fold logic.
### Fold commands
Status | Command | Description
---|--------|------------------------------
:x: | zf{motion} or {Visual}zf | Operator to create a fold.
:x: | zF | Create a fold for [count] lines. Works like "zf".
:x: | zd | Delete one fold at the cursor.
:x: | zD | Delete folds recursively at the cursor.
:x: | zE | Eliminate all folds in the window.
:warning: :x: | zo | Open one fold under the cursor.When a count is given, that many folds deep will be opened.
:white_check_mark: | zO | Open all folds under the cursor recursively.
:warning: :x: | zc | Close one fold under the cursor. When a count is given, that many folds deep are closed.
:white_check_mark:| zC | Close all folds under the cursor recursively.
:x: | za | When on a closed fold: open it. When on an open fold: close it and set 'foldenable'.
:x: | zA | When on a closed fold: open it recursively. When on an open fold: close it recursively and set 'foldenable'.
:x: | zv | View cursor line: Open just enough folds to make the line in which the cursor is located not folded.
:x: | zx | Update folds: Undo manually opened and closed folds: re-apply 'foldlevel', then do "zv": View cursor line.
:x: | zX | Undo manually opened and closed folds
:x: | zm | Fold more: Subtract one from 'foldlevel'.
:white_check_mark: | zM | Close all folds: set 'foldlevel' to 0. 'foldenable' will be set.
:x: | zr | Reduce folding: Add one to 'foldlevel'.
:white_check_mark: | zR | Open all folds. This sets 'foldlevel' to highest fold level.
| zn | Fold none: reset 'foldenable'. All folds will be open.
| zN | Fold normal: set 'foldenable'. All folds will be as they were before.
| zi | Invert 'foldenable'.
:x: | [z | Move to the start of the current open fold.
:x: | ]z | Move to the end of the current open fold.
:x: | zj | Move downwards to the start of the next fold.
:x: | zk | Move upwards to the end of the previous fold.
### Fold options
Status | Command | Description
---|--------|------------------------------
:x: | foldlevel | 'foldlevel' is a number option: The higher the more folded regions are open.
:x: | foldtext | 'foldtext' is a string option that specifies an expression. This expression is evaluated to obtain the text displayed for a closed fold.
:x: | foldcolumn | 'foldcolumn' is a number, which sets the width for a column on the side of the window to indicate folds.
| foldenable fen | Open all folds while not set.
:x: | foldexpr fde | Expression used for "expr" folding.
:x: | foldignore fdi | Characters used for "indent" folding.
:x: | foldmarker fmr | Defined markers used for "marker" folding.
:x: | foldmethod fdm | Name of the current folding method.
:x: | foldminlines fml | Minimum number of screen lines for a fold to be displayed closed.
:x: | foldnestmax fdn | Maximum nesting for "indent" and "syntax" folding.
:x: | foldopen fdo | Which kinds of commands open closed folds.
:x: | foldclose fcl | When the folds not under the cursor are closed.

View File

@ -1130,18 +1130,55 @@ class CommandDot extends BaseCommand {
}
}
@RegisterAction
class CommandFold extends BaseCommand {
abstract class CommandFold extends BaseCommand {
modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine];
keys = ["z", "c"];
commandName: string;
public async exec(position: Position, vimState: VimState): Promise<VimState> {
await vscode.commands.executeCommand("editor.fold");
await vscode.commands.executeCommand(this.commandName);
vimState.currentMode = ModeName.Normal;
return vimState;
}
}
@RegisterAction
class CommandCloseFold extends CommandFold {
keys = ["z", "c"];
commandName = "editor.fold";
}
@RegisterAction
class CommandCloseAllFolds extends CommandFold {
keys = ["z", "M"];
commandName = "editor.foldAll";
}
@RegisterAction
class CommandOpenFold extends CommandFold {
keys = ["z", "o"];
commandName = "editor.unfold";
}
@RegisterAction
class CommandOpenAllFolds extends CommandFold {
keys = ["z", "R"];
commandName = "editor.unfoldAll";
}
@RegisterAction
class CommandCloseAllFoldsRecursively extends CommandFold {
modes = [ModeName.Normal];
keys = ["z", "C"];
commandName = "editor.foldRecursively";
}
@RegisterAction
class CommandOpenAllFoldsRecursively extends CommandFold {
modes = [ModeName.Normal];
keys = ["z", "O"];
commandName = "editor.unFoldRecursively";
}
@RegisterAction
class CommandCenterScroll extends BaseCommand {
modes = [ModeName.Normal];
@ -1157,42 +1194,6 @@ class CommandCenterScroll extends BaseCommand {
}
}
@RegisterAction
class CommandUnfold extends BaseCommand {
modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine];
keys = ["z", "o"];
public async exec(position: Position, vimState: VimState): Promise<VimState> {
await vscode.commands.executeCommand("editor.unfold");
vimState.currentMode = ModeName.Normal;
return vimState;
}
}
@RegisterAction
class CommandFoldAll extends BaseCommand {
modes = [ModeName.Normal];
keys = ["z", "C"];
public async exec(position: Position, vimState: VimState): Promise<VimState> {
await vscode.commands.executeCommand("editor.foldAll");
return vimState;
}
}
@RegisterAction
class CommandUnfoldAll extends BaseCommand {
modes = [ModeName.Normal];
keys = ["z", "O"];
public async exec(position: Position, vimState: VimState): Promise<VimState> {
await vscode.commands.executeCommand("editor.unfoldAll");
return vimState;
}
}
@RegisterAction
class CommandUndo extends BaseCommand {
modes = [ModeName.Normal];