tomrijndorp / vscode-finditfaster

Find it, but faster! Fast file search for VS Code.
MIT License
299 stars 29 forks source link

Add a setting to open the terminal inside of the active editor panel #70

Open MangelMaxime opened 9 months ago

MangelMaxime commented 9 months ago

Hello,

When using "find-it-faster.general.restoreFocusTerminal": true, if the user add a terminal open before invoking vscode-finditfaster, then the console panel will be open even if it was closed before.

This is not something we can control, because we can't know the terminal panel state (lack of VSCode API).

https://github.com/tomrijndorp/vscode-finditfaster/assets/4760796/c396bdcd-8dad-4a37-bd35-4269a1b6dde0

A workaround to this problem, is to drag and drop the "Find It Faster terminal" in the editor section. Like that the terminal panel is not touched by the extension and will stay in its current state:

https://github.com/tomrijndorp/vscode-finditfaster/assets/4760796/adb08b35-4b29-4600-b2ad-bf213fbad462

Would you be open to adding a new setting allowing the user to configure if he wants the terminal to open inside of the Terminal panel or inside of the editor?

The changes required are (hardcoded as I was just exploring the feasibility):

function createTerminal() {
    term = vscode.window.createTerminal({
        name: 'F️indItFaster',
        // hideFromUser: true,
        location: vscode.TerminalLocation.Editor,
        env: {
            /* eslint-disable @typescript-eslint/naming-convention */
        // ...

Note that I needed to comment hideFromUser: true otherwise, the terminal always appear in the terminal panel. I believe this is a bug / limitation of VSCode. As in theory, nothing prevent them to open the terminal and re-focus the previous active editor to make it "hidden" from the user.

Would you be open to adding such feature?

MangelMaxime commented 9 months ago

For reference, I wanted this feature because I wanted to benefit from a combination of restoreFocusTerminal and showMaximizedTerminal because I often have terminals open in VSCode but always wanted to have the search happen in a bigger window.

After playing with VSCode commands it seems like we can restore the original size of the terminal panel by using View: Move panel to Bottom.

Perhaps executing this command when showMaximizedTerminal is set could be an easier implementation. I am saying that because if the terminal is inside of the editors section, if the user press Esc then ATM the moment the terminal stays visible and focuses instead of returning to the previous active editors. And it seems like there would be more edges cases like that to cover and which could make the implementation more complex.

https://github.com/tomrijndorp/vscode-finditfaster/assets/4760796/ae5d110b-1974-4de1-b714-e4b343c21deb

Edit: It seems like it only works if the panel doesn't have focus. I will open an issue on VSCode to see if this is normal. https://github.com/microsoft/vscode/issues/205584