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

Topmost Record Becomes Invalid When Tab Number Changes #3

Open
Jack251970 opened this issue Jan 9, 2025 · 9 comments
Open

Topmost Record Becomes Invalid When Tab Number Changes #3

Jack251970 opened this issue Jan 9, 2025 · 9 comments

Comments

@Jack251970
Copy link

Jack251970 commented Jan 9, 2025

When I set the record of one specific workspace to the topmost, I find that if I change the tab number of this workspace, this record will not be the topmost record anymore.

After checking the TopmostRecord.json file of the FL, I find the workspace record seems to record the tab number in the subtitle, which causes this issue.

image

In this screenshot, ew is my keyword of your plugin. And Latex Formula workspace is not the topmost record because the tab number changes to 5.

image

A possible solution is to use other property rather than subtitle to record the information of the current subtitle.

@cspotcode
Copy link
Owner

I see, so every time the subtitle changes, Flow believes it is a brand new workspace, and the previous workspace -- the one you pinned as topmost -- has disappeared.

A possible solution is to use other property rather than subtitle to record the information of the current subtitle.

I want the total # of tabs to appear visually in Flow's list. Is there away to preserve the current visual presentation at the same time as fixing your issue?

@cspotcode
Copy link
Owner

I believe this is the relevant docs page.
https://www.flowlauncher.com/docs/#/API-Reference/Flow.Launcher.Plugin/Result

Can you suggest a way to tell Flow Launcher to index the topmostrecord using a different key, avoiding subtitle? That way, we preserve the current subtitle while fixing your issue.

@Jack251970
Copy link
Author

I believe this is the relevant docs page.
https://www.flowlauncher.com/docs/#/API-Reference/Flow.Launcher.Plugin/Result

Can you suggest a way to tell Flow Launcher to index the topmostrecord using a different key, avoiding subtitle? That way, we preserve the current subtitle while fixing your issue.

Can TitleTooltip help?

If you want to keep displaying the subtitle, the only way is to create a PR to FL for this feature.

@Jack251970
Copy link
Author

@cspotcode Another way is to implement the pinning feature.

You need to implement the context menu interface and save the pinned records in the local folder like plugin folder. Every time you provide scores of records, plugin need to give pinned records a large value like 1000000. (This can help users have many topmost records and will solve the problem that FL can only has one topmost record for one specific search.)

If you think this is too complex, just wait for my PR to FL for this feature, which let FL ignore subtitle when checking topmost records.

@cspotcode
Copy link
Owner

Sounds good, this does sound like Flow's responsibility, and should be plugin-agnostic. Please link your FL PR on this ticket, it will be helpful to follow along.

@Jack251970
Copy link
Author

Please see Flow-Launcher/Flow.Launcher#3178.

Here are some codes for your reference if this PR can be merged:

// Give this function to result.GetSubTitleKey
string GetSubTitleKey(string subTitle)
{
    var regex = new Regex(@"^Workspace: Profile \w+,");
    var match = regex.Match(subTitle);
    return match.Success ? match.Value : subTitle;
}

string str1 = "Workspace: Profile Default, 4 tabs";

Console.WriteLine(GetSubTitleKey(str1)); // Workspace: Profile Default,

@cspotcode
Copy link
Owner

Would it be simpler for my plugin to pass a recordKey value to Flow Launcher? That way I can specify any unique key I want, and Flow Launcher will use it, ignoring title and subtitle. My plugin gets full control and can modify title or subtitle without breaking TopmostRecord. This allows you to change number of tabs in a workspace or change the name of the workspace.

Your code example shows a function written in C#. How would JSON-RPC plugins use it?

@Jack251970
Copy link
Author

Would it be simpler for my plugin to pass a recordKey value to Flow Launcher? That way I can specify any unique key I want, and Flow Launcher will use it, ignoring title and subtitle. My plugin gets full control and can modify title or subtitle without breaking TopmostRecord. This allows you to change number of tabs in a workspace or change the name of the workspace.

FL uses title and subtitle for identifying one record. So recordKey is not a good idea and it can make the old record data unable to work.

My solution is to let plugin filter the title and subtitle so that old version is compatible.

Your code example shows a function written in C#. How would JSON-RPC plugins use it?

I have little experience of this. Sorry I cannot help.

@Jack251970
Copy link
Author

Now I create new PR for RecordKey, and hopefully it can be merged so that we can fix this issue in the next version of FL.

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