main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
871 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | function emptyScalarPosition(offset, before, pos) {
|
---|
4 | if (before) {
|
---|
5 | if (pos === null)
|
---|
6 | pos = before.length;
|
---|
7 | for (let i = pos - 1; i >= 0; --i) {
|
---|
8 | let st = before[i];
|
---|
9 | switch (st.type) {
|
---|
10 | case 'space':
|
---|
11 | case 'comment':
|
---|
12 | case 'newline':
|
---|
13 | offset -= st.source.length;
|
---|
14 | continue;
|
---|
15 | }
|
---|
16 | // Technically, an empty scalar is immediately after the last non-empty
|
---|
17 | // node, but it's more useful to place it after any whitespace.
|
---|
18 | st = before[++i];
|
---|
19 | while (st?.type === 'space') {
|
---|
20 | offset += st.source.length;
|
---|
21 | st = before[++i];
|
---|
22 | }
|
---|
23 | break;
|
---|
24 | }
|
---|
25 | }
|
---|
26 | return offset;
|
---|
27 | }
|
---|
28 |
|
---|
29 | exports.emptyScalarPosition = emptyScalarPosition;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.