nemesv / vscode-copy-file-name

Extension for Visual Studio Code for coping the name of the currently active file.
https://marketplace.visualstudio.com/items?itemName=nemesv.copy-file-name
MIT License
8 stars 1 forks source link

Option to add trailing line number to filename #5

Open carloxff opened 3 years ago

carloxff commented 3 years ago

It would be wonderful to have an option to add the currently selected line number to the filename, in this form:

filename.cpp:1234

This would be very useful for setting breakpoints into an external GDB debugger, for example.

I have locally modified your code to do this in my VSCode instance, but I think it could be useful for the public.

Nice extension, thanks!

nemesv commented 3 years ago

Interesting idea. Could you post your modified code here, or create a PR from it?

carloxff commented 3 years ago

Hi,

I think my changes were made on an older version of the code (from installation package), so I suppose it's better to paste here the modified call:

Just replace this line:

        pasteAndShowMessage(fileName);

With this statement:

        if (vscode.window.activeTextEditor.selection.isEmpty) {
          pasteAndShowMessage(fileName);
        }
        else {
          const currentLine = vscode.window.activeTextEditor.selection.active.line + 1;
          pasteAndShowMessage(fileName + ':' + currentLine);
        }

Regards

nemesv commented 3 years ago

Thanks for the snippet! I will try to include this in the next version.

vakokako commented 1 year ago

Second that, would be nice to have it as a feature