Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dam024
Copy link
Contributor

@dam024 dam024 commented Apr 20, 2025

In Phantom mode, created a new setting to only integrate the AI generated code without its comments and other markdown syntax. This new feature will extract from the AI generated answer the content of multiline code blocks when integrating the AI answer in a code file in any way. This will happen when the user will click on one of the following option (in phantom mode): Copy, Append, Replace, In New Tab.

The motivation behind this modification is to be able to directly generate code from the AI model and include it in the working file without all the AI comments and the markdown code block delimiters.

In Phantom mode, created a new setting to only integrate the AI generated code without its comments and other markdown syntax.
Copy link
Owner

@yaroslavyaroslav yaroslavyaroslav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for the contribution to this long waited feature.

I'd love to merge your PR after a few minor style issues fixes.


# clear modules cache if package is reloaded (after update?)
prefix = __package__ + '.plugins' # type: ignore # don't clear the base package
for module_name in [module_name for module_name in sys.modules if module_name.startswith(prefix)]:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please revert all of these formatting changes, as they're not the subject of the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted this file. It should be fine now.

plugins/utils.py Outdated
import re


def extract_code_blocks(md_text: str):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add return type hint for that func to compline with the rest of the code style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done it

self.phantom_id: int | None = None
self.user_input = user_input
self.is_discardable: bool = (
load_settings('openAI.sublime-settings')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the changes in this file are formatting ones, which are made b the rules which are differs from the ones that are set within this project .ruff linterconfig.

Could you please reformat the file with respect to that linter rules?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine now, please let me know if there is anything else :)

dam024 added 3 commits April 21, 2025 09:11
Correct some formatting issues
Correct some formatting issues
Correct some formatting issues
Copy link
Owner

@yaroslavyaroslav yaroslavyaroslav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, few last things to fix

)
from .plugins.worker_running_context import ( # noqa: E402,
OpenaiWorkerRunningContext, # noqa: F401
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please bring back new line at the end of file. I expect that this file will be eliminated from within the PR completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, got it

plugins/utils.py Outdated
pattern = re.compile(r"```(?:[^\n`]*)\n([\s\S]*?)```")

# Remove all inline blocks that the model may generate (i.e. code blocks that are inline with the text or that are single line)
filtered = re.sub(r"```([^\n]*?)```", "", md_text)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please apply linter for that new file also (it's "" instead of '' stuff mostly).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've done it.

Correct some formatting issues
@yaroslavyaroslav yaroslavyaroslav merged commit 970274f into yaroslavyaroslav:develop Apr 22, 2025
@dam024
Copy link
Contributor Author

dam024 commented Apr 22, 2025

Sorry about all the formatting issues, I'm using the python-black plugin that reformats automatically everything with another style. Maybe next time can you share which plugin you use for auto formatting? That way next time I can use the same...

@yaroslavyaroslav
Copy link
Owner

Yeah, sure it's ST lsp-ruff plugin, which has to auto pick up .ruff rules stored in the root of the wd.

Thank you once again for contribution, I'll release new version in PC shortly.

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