版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 1 година
123456789101112131415161718192021222324252627
  1. function emptyScalarPosition(offset, before, pos) {
  2. if (before) {
  3. if (pos === null)
  4. pos = before.length;
  5. for (let i = pos - 1; i >= 0; --i) {
  6. let st = before[i];
  7. switch (st.type) {
  8. case 'space':
  9. case 'comment':
  10. case 'newline':
  11. offset -= st.source.length;
  12. continue;
  13. }
  14. // Technically, an empty scalar is immediately after the last non-empty
  15. // node, but it's more useful to place it after any whitespace.
  16. st = before[++i];
  17. while (st?.type === 'space') {
  18. offset += st.source.length;
  19. st = before[++i];
  20. }
  21. break;
  22. }
  23. }
  24. return offset;
  25. }
  26. export { emptyScalarPosition };