Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update metadata.md #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 130 additions & 11 deletions docs/reference/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,54 +175,173 @@ Indentation options control aspects of the auto-indentation mechanism.
`increaseIndentPattern`
: *Regex.*
If it matches on the current line,
the next line will be indented one level further.
lines after current line will be indented one level further.

If in `.tmPreferences`:

```xml
<key>increaseIndentPattern</key>
<string>insert regex here</string>
<string><![CDATA[^\s*increase]]></string>
```

Then, in the corresponding buffer view:

```
line1
line2
increase
after increase1
after increase2
```

`decreaseIndentPattern`
: *Regex.*
If it matches on the current line,
the next line will be unindented one level.
current line and lines after current line will be unindented one level.

If in `.tmPreferences`:

```xml
<key>decreaseIndentPattern</key>
<string>insert regex here</string>
<string><![CDATA[^\s*decrease]]></string>
```

Then, in the corresponding buffer view:

```
line1
line2
decrease
after decrease1
after decrease2
```

`bracketIndentNextLinePattern`
: *Regex.*
If it matches on the current line,
only the next line will be indented one level further.
only the next non-whitespace line will be indented one level further.

If in `.tmPreferences`:

```xml
<key>bracketIndentNextLinePattern</key>
<string>insert regex here</string>
<string><![CDATA[^\s*bracket]]></string>
```

Then, in the corresponding buffer view:

```
line1
line2
line3
bracket

first non-whitespace line after bracket
after bracket2
after bracket3
```

`disableIndentNextLinePattern`
: *Regex.*
If it matches on the current line,
the next line will not be indented further.
and `bracketIndentNextLinePattern`'s *Regex* also matches on the current line.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't bracketIndentNextLinePattern have matched on the previous line?
https://forum.sublimetext.com/t/everything-you-n-ever-wanted-to-know-about-indentation-in-st3/26207?u=kingkeith

The auto-indenter will ignore the effects made by `bracketIndentNextLinePattern`
when computing the indentation level of lines after current line.

If in `.tmPreferences`:

```xml
<key>bracketIndentNextLinePattern</key>
<string><![CDATA[^\s*[A-z]]]></string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex is basically equivalent to \S for all the examples following, so we might as well simplify it to that as to not make it more complex that it needs to be. It will basically match on every non-blank line.

<key>disableIndentNextLinePattern</key>
<string>insert regex here</string>
<string><![CDATA[^\s*disable]]></string>
```

Then, in the corresponding buffer view:

```xml
lineone only match bracketIndentNextLinePattern Regex effects made
after lineone1
after lineone2
disable both match bracketIndentNextLinePattern and disableIndentNextLinePattern Regex effects for lines below ignored
after disable1
after disable2
```

`unIndentedLinePattern`
: *Regex.*
If it matches on the current line,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally think the current wording we have is clearer. It doesn't check if the other regex patterns match, its irrelevant.

and `increaseIndentPattern` and/or `decreaseIndentPattern` and/or `bracketIndentNextLinePattern` *Regex* also matches on the current line.
The auto-indenter will ignore
lines matching this regex
when computing the next line's indentation level.
the effects made by `increaseIndentPattern` and/or `decreaseIndentPattern` and/or `bracketIndentNextLinePattern`
when computing the indentation level of lines after current line.

If in `.tmPreferences`:

```xml
<key>increaseIndentPattern</key>
<string><![CDATA[^\s*[A-z]+]]></string>
<key>unIndentedLinePattern</key>
<string>insert regex here</string>
<string><![CDATA[^\s*unindented]]></string>
```

Then, in the corresponding buffer view:

```xml
lineone only match increaseIndentPattern Regex effects made
after lineone1
after lineone2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have to test this locally, but I would have expect this line to be indented further.

In general, I feel like the "examples" are a bit hard to understand because there are no steps for reproduction, i.e. the user cannot really use a mental model to apply the same rules as ST does for the indentation settings. Or at least I have a problem with it.

I believe it will be easier to understand if the examples showed the result of a reindent command having run on the entire example text, similar to how indentation tests function.

linetwo only match increaseIndentPattern Regex effects made
after linetwo1
after linetwo2
unindented both match increaseIndentPattern and unIndentedLinePattern Regex effects for lines below ignored
after unindented1
after unindented2
```

If in `.tmPreferences`:

```xml
<key>decreaseIndentPattern</key>
<string><![CDATA[^\s*[A-z]+]]></string>
<key>unIndentedLinePattern</key>
<string><![CDATA[^\s*unindented]]></string>
```

Then, in the corresponding buffer view:

```xml
0START0
lineone only match decreaseIndentPattern Regex effects made
after lineone1
after lineone2
linetwo only match decreaseIndentPattern Regex effects made
after linetwo1
after linetwo2
unindented both match decreaseIndentPattern and unIndentedLinePattern Regex effects for lines below ignored
after unindented1
after unindented2
```

If in `.tmPreferences`:

```xml
<key>bracketIndentNextLinePattern</key>
<string><![CDATA[^\s*[A-z]]]></string>
<key>unIndentedLinePattern</key>
<string><![CDATA[^\s*unindented]]></string>
```

Then, in the corresponding buffer view:

```xml
lineone only match bracketIndentNextLinePattern Regex effects made
after lineone1
after lineone2
unindented both match bracketIndentNextLinePattern and unIndentedLinePattern Regex effects for lines below ignored
after unindented1
after unindented2
```

### Completions Options

Expand Down