Skip to content

Commit 9d6350a

Browse files
authored
Update code-description.md
1 parent a8ccf45 commit 9d6350a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

code-description.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ for (let elementNumber = currentTagSpan.length - 1; elementNumber >= 0; elementN
192192

193193
For each tag span element in the array we:
194194
- Look up the tag span ID (`currentTagSpan[elementNumber]`) in the `versionTags` array.
195-
- Get the tag set ID from the `tagSet` property and assign it to `currentTagSetID`.
195+
- Get the tag set ID from the `tagSet` property of the element we find in the `versionTags` array, and assign it to `currentTagSetID`.
196196
- Find all the tags in the `versionTags` array that have the same tag set ID, and for each of these:
197197
- Get the start and end positions of the tag.
198198
- Add the start and end positions to an array of text ranges. We'll highlight these ranges in the editor.
@@ -336,7 +336,7 @@ This is a recap of what we do for each type of version tag we find when we're pa
336336
When we find an `ifversion` tag we:
337337
- Increment `tagCounter`, to use as a unique ID for this tag. This variable needs to survive from one tag processing to the next.
338338
- Increment `nestingLevel`. Initially this is -1, so this becomes 0 for an un-nested tag set and 1 for the first nesting level. This variable needs to survive from one tag processing to the next
339-
- Assign `tagCounter` to `tagSet[nestingLevel]`. This is the ID of the tag set that this tag belongs to (always the same as the ifversion ID). This array needs to survive from one tag processing to the next.
339+
- Assign `tagCounter` to `tagSetID[nestingLevel]`. This is the ID of the tag set that this tag belongs to (always the same as the ifversion ID). This array needs to survive from one tag processing to the next.
340340
- Get the start and end positions of the tag (i.e. the position of `{` and `}`) and assign them to `positionVersionTagStart` and `positionVersionTagEnd`. We do this using the `match` array that contains the tag text (e.g. `{% ifversion ghes %}`) that we found using the regular expression. We do this as follows:
341341

342342
```
@@ -359,7 +359,7 @@ When we find an `ifversion` tag we:
359359
- Set `elsedVersions` to `"NOT " + versionDescription[nestingLevel]` (e.g. "NOT ghes"). For nested `ifversion` tags we prepend "\nAND " to the start of the string. This variable needs to survive from one tag processing to the next, so that we can build up a string that describes the versioning for the `else` tag in the tag set.
360360
- Create a new element in the `versionTags` array, containing these properties:
361361
- **tagID**: The unique ID (`tagCounter` number).
362-
- **tagSet**: The tag set ID (`tagSet[nestingLevel]` number).
362+
- **tagSet**: The tag set ID (`tagSetID[nestingLevel]` number).
363363
- **versionDescription**: The version description (`versionDescription` array of strings).
364364
- **positionVersionTagStart**: The start position of the tag (`positionVersionTagStart` vscode.Position).
365365
- **positionVersionTagEnd**: The end position of the tag (`positionVersionTagEnd` vscode.Position).
@@ -371,11 +371,11 @@ When we find an `elsif` tag we:
371371
- Increment `tagCounter`, to use as a unique ID for this tag.
372372
- Get the start and end positions of the tag (i.e. the position of `{` and `}`) and assign them to `positionVersionTagStart` and `positionVersionTagEnd`.
373373
- Check whether the cursor position is after the end position of the tag. If it is, we:
374-
- Assign `tagSet[nestingLevel]` to `currentTagSpan[nestingLevel]`.
374+
- Assign `tagSetID[nestingLevel]` to `currentTagSpan[nestingLevel]`.
375375
- Get the version from the tag (e.g. "ghec").
376376
- Assign the version to `versionDescription[nestingLevel]`.
377377
- Set `elsedVersions` to `elsedVersions + " \nAND NOT " + versionDescription[nestingLevel]` (e.g. "NOT ghes \nAND NOT ghec").
378-
- Create a new element in the `versionTags` array, as above. Note that we don't assign a value to `tagSet` because this tag doesn't start a new tag set. It belongs to the same tag set as the `ifversion` tag. So we use the same `tagSet` value as the `ifversion` tag.
378+
- Create a new element in the `versionTags` array, as above. Note that we don't assign a value to `tagSetID[nestingLevel]` because this tag doesn't start a new tag set. It belongs to the same tag set as the `ifversion` tag. So we use the same `tagSetID[nestingLevel]` value that we set for the `ifversion` tag.
379379

380380
#### `else`
381381

@@ -384,10 +384,10 @@ When we find an `else` tag we:
384384
- Increment `tagCounter`, to use as a unique ID for this tag.
385385
- Get the start and end positions of the tag (i.e. the position of `{` and `}`) and assign them to `positionVersionTagStart` and `positionVersionTagEnd`.
386386
- Check whether the cursor position is after the end position of the tag. If it is, we:
387-
- Assign `tagSet[nestingLevel]` to `currentTagSpan[nestingLevel]`.
387+
- Assign `tagSetID[nestingLevel]` to `currentTagSpan[nestingLevel]`.
388388
- If `nestingLevel` is >0, we set `versionDescription[nestingLevel]` to " AND ".
389389
- Set `versionDescription[nestingLevel]` to `versionDescription[nestingLevel] + elsedVersions`.
390-
- Create a new element in the `versionTags` array, as above, again reusing the unmodified `tagSet` value from the `ifversion` tag.
390+
- Create a new element in the `versionTags` array, as above, again reusing the unmodified `tagSetID[nestingLevel]` value that we set for the `ifversion` tag.
391391

392392
#### `endif`
393393

@@ -399,7 +399,7 @@ When we find an `endif` tag we:
399399
- Set `elsedVersions` to `""`.
400400
- Delete the last element in the `versionDescription` and `currentTagSpan` arrays.
401401
- Decrement `nestingLevel`. At each `endif` we're stepping out of a level of nesting, or out of versioning altogether this is the `endif` for an un-nested tag set (in which case `nestingLevel` returns to -1).
402-
- Create a new element in the `versionTags` array, as above, again reusing the unmodified `tagSet` value from the `ifversion` tag.
402+
- Create a new element in the `versionTags` array, as above, again reusing the unmodified `tagSetID[nestingLevel]` value that we set for the `ifversion` tag.
403403

404404
Note: the cursor can never be within an `endif` tag span, because `endif` tags have no tag span. So we'll never use the `tagID` or `versionDescription` properties of an `endif` tag. We'll only use the `tagSet` property (to identify the `endif` tag to highlight when the cursor is somewhere else within this tag set) and the `positionVersionTagStart` and `positionVersionTagEnd` properties (to tell VS Code which characters to highlight for this tag).
405405

0 commit comments

Comments
 (0)