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

fix(ghost_text): ensure multiline indent is correct #934

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

xzbdmw
Copy link
Contributor

@xzbdmw xzbdmw commented Jan 7, 2025

This pr includes a util function to_static_text that correctly transforms
multiline snippets with regards of current line indent. This function is nearly
a copy of vim.snippet.expand but without really expanding it, to solely get
the yet-to-inserted text.

before:
image

after:
image

@Saghen
Copy link
Owner

Saghen commented Jan 7, 2025

Instead of copying the vim.snippet implementation, perhaps we could simplify this by writing our own, or generally refactor the vim.snippet code to only include the indentation part. mini.snippets recently implemented this in echasnovski/mini.nvim@b1af49d

@xzbdmw
Copy link
Contributor Author

xzbdmw commented Jan 7, 2025

Do you mean that we take the result of to_string(snip) and manipulate the raw text with the correct indentation instead of parsing the snip directly?

@Saghen
Copy link
Owner

Saghen commented Jan 7, 2025

Yep exactly

@xzbdmw
Copy link
Contributor Author

xzbdmw commented Jan 7, 2025

That makes sense, I'll try later.

@xzbdmw xzbdmw force-pushed the ghost-text-indent branch from 669c34e to 80fd925 Compare January 7, 2025 23:10
@xzbdmw xzbdmw force-pushed the ghost-text-indent branch from 80fd925 to d721045 Compare January 8, 2025 14:47
@xzbdmw
Copy link
Contributor Author

xzbdmw commented Jan 8, 2025

I've minimize the code to only adding indentations for raw string.

@Saghen Saghen merged commit b8dbec6 into Saghen:main Jan 8, 2025
2 checks passed
@Saghen
Copy link
Owner

Saghen commented Jan 8, 2025

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants