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

Add a functionality for listing only in the current file #241

Open
Liniik opened this issue Apr 16, 2024 · 3 comments
Open

Add a functionality for listing only in the current file #241

Liniik opened this issue Apr 16, 2024 · 3 comments

Comments

@Liniik
Copy link

Liniik commented Apr 16, 2024

This extension currently works only for all files in a project. I want to be able to list annotations just from the currently opened file. Based on the issue #74 and subsequent commit e81d087 I guess that there was the functionality but was removed?? I have onyl the code actions mentioned in currecnt readme. Please put it back, I have very big project and I want to concentrate only on the current work.

@SaharBahloul
Copy link

You need to change the part of your code that collects annotations to only do so from the currently opened file. Here’s a conceptual modification you can make: function triggerUpdateDecorations() {
if (activeEditor) {
updateDecorations(activeEditor);
}
}

function updateDecorations(editor) {
if (!editor || !editor.document) return;

const text = editor.document.getText();
const matches = [];
let match;
while (match = pattern.exec(text)) {
    const startPos = editor.document.positionAt(match.index);
    const endPos = editor.document.positionAt(match.index + match[0].length);
    const decoration = { range: new vscode.Range(startPos, endPos), hoverMessage: match[0] };
    matches.push(decoration);
}

editor.setDecorations(annotationDecorationType, matches);

}
Ensure that when the extension is activated or when the active editor is changed, the annotations are updated accordingly:vscode.window.onDidChangeActiveTextEditor(editor => {
activeEditor = editor;
if (editor) {
triggerUpdateDecorations();
}
}, null, context.subscriptions);

@Liniik
Copy link
Author

Liniik commented Apr 23, 2024

What are you talking about? Didn't you mean to post it as a PR? I don't have any "my" code. My issue is to let the author know he's missing a feature which was there

@SaharBahloul
Copy link

Hello [@Liniik],

Apologies for the confusion— I realize my previous message may have given the wrong impression. I am not the maintainer of this project nor am I suggesting changes through a PR at this moment.

I was actually expressing a user's perspective, hoping to highlight a feature that was very useful in previous versions and seems to be missing now. My aim was to bring this to the attention of the actual maintainers, as this feature significantly aids in managing large projects.

Thanks for your efforts on this extension, and sorry for any mix-up!

Best regards,
sahar

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

No branches or pull requests

2 participants