Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapsible passages #7

Open
NQNStudios opened this issue Aug 7, 2020 · 11 comments
Open

Collapsible passages #7

NQNStudios opened this issue Aug 7, 2020 · 11 comments
Labels
enhancement New feature or request

Comments

@NQNStudios
Copy link

Thanks for making this!

One thing that would be nice is if I could collapse/expand each passage in a file.

@MxAshUp
Copy link
Owner

MxAshUp commented Aug 7, 2020

Hmmm I always assumed vscode did collapse/expand based on indentation. If you indent a passage, for example, you can collapse it.
Peek 2020-08-06 19-44

But I suspect I'm missing something more to this. Do you have an example using another language of expanding/collapsing that ignores indentations?

@MxAshUp
Copy link
Owner

MxAshUp commented Aug 7, 2020

@NQNStudios
Copy link
Author

NQNStudios commented Aug 7, 2020

I didn't realize indentation was such a convenient way to fold anything in VSCode! Good to know.

But yeah, what I was thinking was that they shouldn't be required, ::[title] would automatically be collapsible. But I wonder if the configuration you linked would throw a fit if the start of the next region has to be the end of the first region.

i.e.

{
  "folding": {
    "markers": {
      "start": "^::.*$",
      "end":   "^::.*$"      <-- Would this match then be ignored as the start of another region?
    }
  }
}

@MxAshUp
Copy link
Owner

MxAshUp commented Aug 7, 2020

I was just giving something like that a try, but you're right, I'm not sure how to tell it that the start of the next region is the end of the current one.

The closest I've got to something working is:

{
    "markers": {
      "start": "^::.*$",
      "end":   ""
    }

This will only fold the first line in the passage.
I'm reading through the docs to see what we could work with.

Also interesting, I couldn't get \n to match. I tried setting end to \n\n or ^\n but it seems it's matching on a line-by-line basis.

@NQNStudios
Copy link
Author

NQNStudios commented Aug 7, 2020

Maybe this hacky way would work:

"start": ":?:.*$",
"end": "^:"

Problem is it would probably start picking up colons that appear in embedded scripts.
Fixed (?) that by changing a . to a :

@MxAshUp
Copy link
Owner

MxAshUp commented Aug 7, 2020

Ah I see where you're going with that. Didn't seem to work though. (btw if you clone this repo, open with VS code and go to run->start debugging you can give these a try)

I think what VSCode is doing is labeling each line as either a start marker or end marker. And if a line is both, it ignores it(?)

@NQNStudios
Copy link
Author

NQNStudios commented Aug 10, 2020 via email

@MxAshUp
Copy link
Owner

MxAshUp commented Aug 10, 2020

Clever idea! Yeah definitely something that would be optional.

Another approach would be to implement a language server. This allows an extension to analyze an entire document, and return various interpretations about it, folding regions being one of them. Might be worth the effort.

@NQNStudios
Copy link
Author

NQNStudios commented Aug 11, 2020 via email

@MxAshUp
Copy link
Owner

MxAshUp commented Aug 11, 2020 via email

@MxAshUp
Copy link
Owner

MxAshUp commented Aug 17, 2020

Someone just started another twee extension, and they've made a ton more progress than I have here. They still don't have collapsible passages, but it may be easier to implement with what they have started. I opened this same issue over there: cyrusfirheir/twee3-language-tools#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants