diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-10-15 17:48:17 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-10-15 17:48:17 +0100 |
commit | a230b438e025c5878b8d17e11d3928cbad95bb28 (patch) | |
tree | 231872915ede46874b6e7d2b3d1240d1defa5231 /editors/code | |
parent | e031b65f93f73164a5729cf81ff60299708bc931 (diff) | |
parent | 2bc9e9f32711047b06940c335eb5327281f8c555 (diff) |
Merge #127
127: Improve folding r=matklad a=aochagavia
I was messing around with adding support for multiline comments in folding and ended up changing a bunch of other things.
First of all, I am not convinced of folding groups of successive items. For instance, I don't see why it is worthwhile to be able to fold something like the following:
```rust
use foo;
use bar;
```
Furthermore, this causes problems if you want to fold a multiline import:
```rust
use foo::{
quux
};
use bar;
```
The problem is that now there are two possible folds at the same position: we could fold the first use or we could fold the import group. IMO, the only place where folding groups makes sense is when folding comments. Therefore I have **removed folding import groups in favor of folding multiline imports**.
Regarding folding comments, I made it a bit more robust by requiring that comments can only be folded if they have the same flavor. So if you have a bunch of `//` comments followed by `//!` comments, you will get two separate fold groups instead of a single one.
Finally, I rewrote the API in such a way that it should be trivial to add new folds. You only need to:
* Create a new FoldKind
* Add it to the `fold_kind` function that converts from `SyntaxKind` to `FoldKind`
Fixes #113
Co-authored-by: Adolfo OchagavĂa <[email protected]>
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/src/extension.ts | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index ff8f23c7a..d1c525f68 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts | |||
@@ -20,8 +20,8 @@ export function activate(context: vscode.ExtensionContext) { | |||
20 | f: (...args: any[]) => Promise<boolean> | 20 | f: (...args: any[]) => Promise<boolean> |
21 | ) { | 21 | ) { |
22 | const defaultCmd = `default:${name}`; | 22 | const defaultCmd = `default:${name}`; |
23 | const original = async (...args: any[]) => | 23 | const original = (...args: any[]) => |
24 | await vscode.commands.executeCommand(defaultCmd, ...args); | 24 | vscode.commands.executeCommand(defaultCmd, ...args); |
25 | 25 | ||
26 | registerCommand(name, async (...args: any[]) => { | 26 | registerCommand(name, async (...args: any[]) => { |
27 | const editor = vscode.window.activeTextEditor; | 27 | const editor = vscode.window.activeTextEditor; |