@packtrack/layout 1.6.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,18 @@ export class Span {
12
12
  if (this.inside.includes(position.section)) {
13
13
  return true;
14
14
  }
15
+ if (position.section == this.head.section && position.section == this.tail.section) {
16
+ if (this.head.reversed) {
17
+ if (this.head.absolutePosition > position.absolutePosition && this.tail.absolutePosition < position.absolutePosition) {
18
+ return true;
19
+ }
20
+ }
21
+ else {
22
+ if (this.head.offset < position.absolutePosition && this.tail.offset > position.absolutePosition) {
23
+ return true;
24
+ }
25
+ }
26
+ }
15
27
  if (position.section == this.head.section) {
16
28
  if (this.head.reversed) {
17
29
  if (this.head.absolutePosition > position.absolutePosition) {
@@ -42,6 +54,10 @@ export class Span {
42
54
  return this.contains(peer.head) || this.contains(peer.tail);
43
55
  }
44
56
  get length() {
57
+ // TODO verify reverse
58
+ if (this.head.section == this.tail.section) {
59
+ return Math.abs(this.head.offset - this.tail.offset);
60
+ }
45
61
  let length = 0;
46
62
  if (this.head.reversed) {
47
63
  length += this.head.section.length - this.head.offset;
@@ -52,11 +68,12 @@ export class Span {
52
68
  for (let section of this.inside) {
53
69
  length += section.length;
54
70
  }
71
+ // TODO verify
55
72
  if (this.tail.reversed) {
56
- length += this.tail.section.length - this.tail.offset;
73
+ length += this.tail.offset;
57
74
  }
58
75
  else {
59
- length += this.tail.offset;
76
+ length += this.tail.section.length - this.tail.offset;
60
77
  }
61
78
  return length;
62
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@packtrack/layout",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "type": "module",
5
5
  "main": ".built/index.js",
6
6
  "typings": ".built/index.d.ts",
package/source/span.ts CHANGED
@@ -14,6 +14,18 @@ export class Span {
14
14
  return true;
15
15
  }
16
16
 
17
+ if (position.section == this.head.section && position.section == this.tail.section) {
18
+ if (this.head.reversed) {
19
+ if (this.head.absolutePosition > position.absolutePosition && this.tail.absolutePosition < position.absolutePosition) {
20
+ return true;
21
+ }
22
+ } else {
23
+ if (this.head.offset < position.absolutePosition && this.tail.offset > position.absolutePosition) {
24
+ return true;
25
+ }
26
+ }
27
+ }
28
+
17
29
  if (position.section == this.head.section) {
18
30
  if (this.head.reversed) {
19
31
  if (this.head.absolutePosition > position.absolutePosition) {
@@ -46,6 +58,11 @@ export class Span {
46
58
  }
47
59
 
48
60
  get length() {
61
+ // TODO verify reverse
62
+ if (this.head.section == this.tail.section) {
63
+ return Math.abs(this.head.offset - this.tail.offset);
64
+ }
65
+
49
66
  let length = 0;
50
67
 
51
68
  if (this.head.reversed) {
@@ -58,10 +75,11 @@ export class Span {
58
75
  length += section.length;
59
76
  }
60
77
 
78
+ // TODO verify
61
79
  if (this.tail.reversed) {
62
- length += this.tail.section.length - this.tail.offset;
63
- } else {
64
80
  length += this.tail.offset;
81
+ } else {
82
+ length += this.tail.section.length - this.tail.offset;
65
83
  }
66
84
 
67
85
  return length;