marcuswestin

marcuswestin

Technical founder, CTO and product architect. I love rapidly taking a product from 0 to launch, designing and coding much of it myself.

Member Since 12 years ago

New York

Experience Points
925
follower
Lessons Completed
1
follow
Lessons Completed
178
stars
Best Reply Awards
113
repos

3181 contributions in the last year

Pinned
⚡ An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews
⚡ Cross-browser storage for all use cases, used across the web.
Activity
Sep
20
1 month ago
Activity icon
issue

marcuswestin issue codemirror/codemirror.next

marcuswestin
marcuswestin

Multi-line Decoration.replace results in viewport not rendering all subsequent lines

I am implementing content-based folding, such that a the content of the document dictates what gets folded - e.g imagine that a line prefixed with [FOLD] will fold all its "child-node" lines in the AST.

It is currently implemented with Decoration.replace, just like the code folding extension, but causes the viewport to fail to render some of the subsequent lines.

Here is an example implementation, which demonstrates the buggy rendering. You can copy and and paste it into demo.ts, and then move the cursor down in the document to see the bug in action:

https://gist.github.com/marcuswestin/f8f5c01094a5e7740f2c3de8a557bd55

Using foldEffect directly does NOT cause this behavior, even though it uses the same Decoration.replace approach under the hood (you can try this by uncommenting the last five lines in the gist, which creates a foldEffect update on the view state).

@marijnh I'd very much appreciate your guidance in understanding what's going wrong here!

Activity icon
issue

marcuswestin issue comment codemirror/codemirror.next

marcuswestin
marcuswestin

Multi-line Decoration.replace results in viewport not rendering all subsequent lines

I am implementing content-based folding, such that a the content of the document dictates what gets folded - e.g imagine that a line prefixed with [FOLD] will fold all its "child-node" lines in the AST.

It is currently implemented with Decoration.replace, just like the code folding extension, but causes the viewport to fail to render some of the subsequent lines.

Here is an example implementation, which demonstrates the buggy rendering. You can copy and and paste it into demo.ts, and then move the cursor down in the document to see the bug in action:

https://gist.github.com/marcuswestin/f8f5c01094a5e7740f2c3de8a557bd55

Using foldEffect directly does NOT cause this behavior, even though it uses the same Decoration.replace approach under the hood (you can try this by uncommenting the last five lines in the gist, which creates a foldEffect update on the view state).

@marijnh I'd very much appreciate your guidance in understanding what's going wrong here!

marcuswestin
marcuswestin

Great, I got it working - here's a naive example that uses the same decoration set creation code, but with a StateField instead of a ViewPlugin:

https://gist.github.com/marcuswestin/89e51bdf95ada35d4ad1b6532ee5f0ef

Thank you very much!

Activity icon
issue

marcuswestin issue comment codemirror/codemirror.next

marcuswestin
marcuswestin

Multi-line Decoration.replace results in viewport not rendering all subsequent lines

I am implementing content-based folding, such that a the content of the document dictates what gets folded - e.g imagine that a line prefixed with [FOLD] will fold all its "child-node" lines in the AST.

It is currently implemented with Decoration.replace, just like the code folding extension, but causes the viewport to fail to render some of the subsequent lines.

Here is an example implementation, which demonstrates the buggy rendering. You can copy and and paste it into demo.ts, and then move the cursor down in the document to see the bug in action:

https://gist.github.com/marcuswestin/f8f5c01094a5e7740f2c3de8a557bd55

Using foldEffect directly does NOT cause this behavior, even though it uses the same Decoration.replace approach under the hood (you can try this by uncommenting the last five lines in the gist, which creates a foldEffect update on the view state).

@marijnh I'd very much appreciate your guidance in understanding what's going wrong here!

marcuswestin
marcuswestin

@marijnh Thank you for the rapid response!

Is it accurate that a State Decoration is effectively a StateField<DecorationSet> which holds and updates all the current decorations that should be applied to the Document State pre-viewport considerations?

If yes: how does the Document State know to interpret the StateField's value as a decoration, and apply it before the view is computed? E.g in fold.ts, I see that foldState gets exported as an extension value in codeFolding(), but I don't understand how a State knows to apply its value as a DecorationSet to its document.

Thanks!

Activity icon
issue

marcuswestin issue codemirror/codemirror.next

marcuswestin
marcuswestin

Multi-line Decoration.replace results in viewport not rendering all subsequent lines

I am implementing content-based folding, such that a the content of the document dictates what gets folded - e.g imagine that a line prefixed with [FOLD] will fold all its "child-node" lines in the AST.

It is currently implemented with Decoration.replace, just like the code folding extension, but causes the viewport to fail to render some of the subsequent lines.

Here is an example implementation, which demonstrates the buggy rendering. You can copy and and paste it into demo.ts, and then move the cursor down in the document to see the bug in action:

https://gist.github.com/marcuswestin/f8f5c01094a5e7740f2c3de8a557bd55

Using foldEffect directly does NOT cause this behavior, even though it uses the same Decoration.replace approach under the hood (you can try this by uncommenting the last five lines in the gist, which creates a foldEffect update on the view state).

@marijnh I'd very much appreciate your guidance in understanding what's going wrong here!

Sep
8
1 month ago
Sep
7
1 month ago
started
started time in 1 month ago
Sep
6
1 month ago
Activity icon
issue

marcuswestin issue comment codemirror/search

marcuswestin
marcuswestin

Add search config option to not match case when search panel is opened

When opening the search panel, I want to be able to have "match case" not active.

This patch adds a search config option to do so.

marcuswestin
marcuswestin

Thank you!

Looking forward to making more contributions 👍

open pull request

marcuswestin wants to merge codemirror/search

marcuswestin
marcuswestin

Add search config option to not match case when search panel is opened

When opening the search panel, I want to be able to have "match case" not active.

This patch adds a search config option to do so.

marcuswestin
marcuswestin

Yes! ?? is right.

It's such a nice operator :)

pull request

marcuswestin merge to codemirror/search

marcuswestin
marcuswestin

Add search config option to not match case when search panel is opened

When opening the search panel, I want to be able to have "match case" not active.

This patch adds a search config option to do so.

push

marcuswestin push wordflower/codemirror-search-fork

marcuswestin
marcuswestin

Use ?? rather than || to default to conjfig matchCase configuration value

commit sha: 8ef9afd1c9a22a9b7bb71274aa02b08deadcb9b9

push time in 1 month ago
push

marcuswestin push wordflower/codemirror-search-fork

marcuswestin
marcuswestin

Use ?? rather than || to default to conjfig matchCase configuration value

commit sha: d2ac3c97e9fad30dd133780564b2681a8abd33f8

push time in 1 month ago
Sep
4
1 month ago
push

marcuswestin push wordflower/codemirror-search-fork

marcuswestin
marcuswestin

Revert "Allow for specifying whether to select the search input content when activated"

This reverts commit da470270e5e17c51f7fc78306e0985e485bd14a4.

marcuswestin
marcuswestin

Always select the search input content when activating the search panel.

See https://github.com/codemirror/search/pull/5 for discussion.

marcuswestin
marcuswestin

Merge branch 'add-search-config-to-select-search-input-content-on-activation'

commit sha: f91cf8f203a256a00e1e067a4a002fe3d9be27b7

push time in 1 month ago
push

marcuswestin push wordflower/codemirror-search-fork

marcuswestin
marcuswestin

Revert "Allow for specifying whether to select the search input content when activated"

This reverts commit da470270e5e17c51f7fc78306e0985e485bd14a4.

marcuswestin
marcuswestin

Always select the search input content when activating the search panel.

See https://github.com/codemirror/search/pull/5 for discussion.

commit sha: df0f0156acd73fcbaf525e4d9d42eb28df6c500c

push time in 1 month ago
Activity icon
issue

marcuswestin issue comment codemirror/search

marcuswestin
marcuswestin

Allow for specifying whether to select the search input content when activated

Prior to this change, when I used the search panel multiple times in the same document the previous search input wouldn't be cleared when I hit Cmd+F.

This patch addresses this problem by adding a "select" option to the search config.

Steps to demo intended behavior

  • Hit Cmd+f
  • Type in "foo". Editor correctly finds "foo"
  • Hit escape
  • Hit Cmd+f
  • Type in "bar". Editor finds "foobar" instead of my expected "bar".

Adding the option "select" means that the previous content "foo" is selected by default when focusing on the search input with Cmd+f, so typing "bar" overrides the previous input.

marcuswestin
marcuswestin

Interesting. I use CodeMirror inside Electron.

I believe we should make it behave the same across all platforms. Making it select by default sounds right to me, since it's definitely the most common search input behavior across platforms and apps.

I'll update this patch.

push

marcuswestin push wordflower/codemirror-search-fork

marcuswestin
marcuswestin

Add search config option to not match case when search panel is opened

marcuswestin
marcuswestin

Merge branch 'add-search-config-to-not-match-case'

commit sha: 2d8e7486dddd6f1976cfd34626b526d3d6b69139

push time in 1 month ago
Activity icon
delete
deleted time in 1 month ago
pull request

marcuswestin pull request codemirror/search

marcuswestin
marcuswestin

Allow for specifying whether to select the search input content when activated

Prior to this change, when I used the search panel multiple times in the same document the previous search input wouldn't be cleared when I hit Cmd+F.

This patch addresses this problem by adding a "select" option to the search config.

Steps to demo intended behavior

  • Hit Cmd+f
  • Type in "foo". Editor correctly finds "foo"
  • Hit escape
  • Hit Cmd+f
  • Type in "bar". Editor finds "foobar" instead of my expected "bar".

Adding the option "select" means that the previous content "foo" is selected by default when focusing on the search input with Cmd+f, so typing "bar" overrides the previous input.

pull request

marcuswestin pull request codemirror/search

marcuswestin
marcuswestin

Allow for specifying whether to select the search input content when activated

Problem: When I use the search panel multiple times, previous search input isn't cleared on subsequent searches.

This patch addresses this problem by adding a "select" option to the search config.

Steps to demo intended behavior

  1. Hit Cmd+f
  2. Type in "foo". Editor correctly finds "foo"
  3. Hit escape
  4. Hit Cmd+f
  5. Type in "bar". Editor finds "foobar" instead of my expected "bar".

Adding the option "select" means that the previous content "foo" is selected by default when focusing on the search input with Cmd+f, so typing "bar" overrides the previous input.

Activity icon
issue

marcuswestin issue comment codemirror/search

marcuswestin
marcuswestin

Allow for specifying whether to select the search input content when activated

Problem: When I use the search panel multiple times, previous search input isn't cleared on subsequent searches.

This patch addresses this problem by adding a "select" option to the search config.

Steps to demo intended behavior

  1. Hit Cmd+f
  2. Type in "foo". Editor correctly finds "foo"
  3. Hit escape
  4. Hit Cmd+f
  5. Type in "bar". Editor finds "foobar" instead of my expected "bar".

Adding the option "select" means that the previous content "foo" is selected by default when focusing on the search input with Cmd+f, so typing "bar" overrides the previous input.

marcuswestin
marcuswestin

I need to merge additional content into the wordflower:main branch, and so I'm going to close this pull request and then open a new one from a specific feature-branch (named "add-search-config-to-not-match-case")

Activity icon
created branch

marcuswestin in wordflower/codemirror-search-fork create branch add-search-config-to-select-search-input-content-on-activation

createdAt 1 month ago
pull request

marcuswestin pull request codemirror/search

marcuswestin
marcuswestin

Add search config option to not match case when search panel is opened

When opening the search panel, I want to be able to have "match case" not active.

This patch adds a search config option to do so.

Activity icon
created branch

marcuswestin in wordflower/codemirror-search-fork create branch add-search-config-to-not-match-case

createdAt 1 month ago
Sep
3
1 month ago
pull request

marcuswestin pull request codemirror/search

marcuswestin
marcuswestin

Allow for specifying whether to select the search input content when activated

Problem: When I use the search panel multiple times, previous search input isn't cleared on subsequent searches.

This patch addresses this problem by adding a "select" option to the search config.

Steps to demo intended behavior

  1. Hit Cmd+f
  2. Type in "foo". Editor correctly finds "foo"
  3. Hit escape
  4. Hit Cmd+f
  5. Type in "bar". Editor finds "foobar" instead of my expected "bar".

Adding the option "select" means that the previous content "foo" is selected by default when focusing on the search input with Cmd+f, so typing "bar" overrides the previous input.

push

marcuswestin push wordflower/codemirror-search-fork

marcuswestin
marcuswestin

Allow for specifying whether to select the search input content when activated

commit sha: da470270e5e17c51f7fc78306e0985e485bd14a4

push time in 1 month ago
Activity icon
created branch
createdAt 1 month ago
Aug
11
2 months ago
push

marcuswestin push marcuswestin/electron-app-boilerplate

marcuswestin
marcuswestin

Boilerplate for typescript react apps with electron, react native and vite

commit sha: 9a4e354694c2bae89acd27815bc758feedca1338

push time in 2 months ago
Previous