Skip to content

Commit

Permalink
#117 Support slurping/barfing from within objects/object-types (#119)
Browse files Browse the repository at this point in the history
* 🚸 Support slurping from nested objects

βœ… Add slurping from nested-object tests

πŸ—οΈ Support custom subject-container-node fns

* 🚸 Support barfing from nested objects

* 🚸 Support slurping from nested object types

* 🚸 Support barfing from nested object types

* πŸ“ Update changelog

* 🚨 Fix linting issue

* 🩹 Handle nested-object-barfing edge cases

* 🩹 Calculate end-node-insert offset properly

Changed to calculate the end-node-text length as the difference between the last end node end index and the first end node start index - this takes into account spacing
  • Loading branch information
sansarip authored Aug 19, 2024
1 parent 3575aeb commit e2c3a13
Show file tree
Hide file tree
Showing 9 changed files with 511 additions and 264 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

All notable changes to the Owlbear extension will be documented in this file.

## [Unreleased]

### Added

- Add slurping/barfing support from within nested objects and object types

## [1.1.6] - 2024-02-23

### Added

- Add remote development support [#114](https://github.com/sansarip/owlbear/issues/114)

## [1.1.5] - 2023-06-04
Expand Down
374 changes: 220 additions & 154 deletions src/cljs/owlbear/ts/edit/barf.cljs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/cljs/owlbear/ts/edit/corpus/barf/arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ foo(() => {β–Œ},bar())
foo(a, b,β–Œ)
```
```typescript
foo(a ,β–Œ)b
foo(a β–Œ)b
```

```typescript
foo(a, b,,,β–Œ)
```
```typescript
foo(a ,,,β–Œ)b
foo(a β–Œ)b
```

```typescript
Expand Down
36 changes: 36 additions & 0 deletions src/cljs/owlbear/ts/edit/corpus/barf/object_literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,39 @@
```typescript
[{β–Œ},a ,1, 2]
```

## In Objects
```typescript
{a: β–Œ{b: c}}
```
```typescript
{a: β–Œ{},b: c}
```

```typescript
{a: β–Œ{b: c, c: d}}
```
```typescript
{a: β–Œ{b: c },c: d}
```

```typescript
{a: β–Œ{[b]: }}
```
```typescript
{a: β–Œ{},b }
```

```typescript
{a: β–Œ{b: }}
```
```typescript
{a: β–Œ{},b }
```

```typescript
{a: β–Œ{b: c,}}
```
```typescript
{a: β–Œ{},b: c}
```
55 changes: 49 additions & 6 deletions src/cljs/owlbear/ts/edit/corpus/barf/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,57 @@
type foo = {a: string;β–Œ}
```
```typescript
type foo = {a: ;β–Œ}string
type foo = {β–Œ};a: string;
```

```typescript
type foo = {a: string;β–Œ};
```
```typescript
type foo = {β–Œ};a: string;
```

```typescript
type foo = {a: stringβ–Œ}
```
```typescript
type foo = {a: β–Œ}string
type foo = {β–Œ};a: string;
```

```typescript
interface foo {a: string;β–Œ}
```
```typescript
interface foo {a: ;β–Œ}string
interface foo {β–Œ};a: string;
```

## Type/Interface with Incomplete Pair
```typescript
type foo = {a:β–Œ}
```
```typescript
type foo = {β–Œ}a
type foo = {β–Œ};a;
```

```typescript
type foo = {a:β–Œ};
```
```typescript
type foo = {β–Œ};a;
```

```typescript
type foo = {a:β–Œ;}
```
```typescript
type foo = {β–Œ}a
type foo = {β–Œ};a;
```

```typescript
interface foo {a:β–Œ}
```
```typescript
interface foo {β–Œ}a
interface foo {β–Œ};a;
```


Expand All @@ -52,4 +66,33 @@ interface bar {a: string}β–Œ};
```ts
declare namespace Foo {
β–Œ}interface bar {a: string};
```

## Nested Object Types
```ts
type foo = {a: β–Œ{b: string; c: string;};}
```
```ts
type foo = {a: β–Œ{b: string; };c: string;}
```
```ts
type foo = {a: β–Œ{b: string; c: string;}}
```
```ts
type foo = {a: β–Œ{b: string; };c: string;}
```
```ts
type foo = {a: β–Œ{b: string;};}
```
```ts
type foo = {a: β–Œ{};b: string;}
```
```ts
type foo = {a: β–Œ{b: string;}}
```
```ts
type foo = {a: β–Œ{};b: string;}
```
55 changes: 54 additions & 1 deletion src/cljs/owlbear/ts/edit/corpus/slurp/object_literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,57 @@ b
```
```typescript
[{[a]: b, [cβ–Œ]:}]
```
```

## In Objects
```typescript
{a: β–Œ{}, b: c}
```
```typescript
{a: β–Œ{ b: c}}
```

```typescript
{a: β–Œ{b: c}, c: d}
```
```typescript
{a: β–Œ{b: c, c: d}}
```

```typescript
{a: {b: cβ–Œ}, c: d}
```
```typescript
{a: {b: c, c: dβ–Œ}}
```

```typescript
{a: β–Œ{b: c, c: d}, b}
```
```typescript
{a: β–Œ{b: c, c: d, [b]:}}
```

```typescript
{a: {b: β–Œ{}, c: d}}
```
```typescript
{a: {b: β–Œ{ c: d}}}
```

```typescript
const foo = {
a: {
β–Œb: number
},
c: string
};
```
```typescript
const foo = {
a: {
β–Œb: number
,
c: string}
};
```
15 changes: 15 additions & 0 deletions src/cljs/owlbear/ts/edit/corpus/slurp/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,18 @@ interface bar {a: string};
declare namespace Foo {
interface bar {a: string}β–Œ};
```

## Nested Object Types
```ts
type foo = {a: β–Œ{b: string;}; c: string;}
```
```ts
type foo = {a: β–Œ{b: string; c: string;};}
```
```ts
type foo = {a: β–Œ{}; b: string;}
```
```ts
type foo = {a: β–Œ{ b: string};}
```
Loading

0 comments on commit e2c3a13

Please sign in to comment.