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

After Diff head option, the tab caption changed to Diff:.. #22

Closed
JairoMartinezA opened this issue Jan 9, 2024 · 18 comments
Closed

After Diff head option, the tab caption changed to Diff:.. #22

JairoMartinezA opened this issue Jan 9, 2024 · 18 comments

Comments

@JairoMartinezA
Copy link

Hi @veksha

Basically

  1. Collect hotspots in git folder
  2. Over a modified file, use Diff head contextual menu option
  3. Is opened a new tab with Diff lexer
  4. Close this later tab
  5. Open again the file with double clic
  6. The tab caption always shows now:

image

@veksha
Copy link
Owner

veksha commented Jan 9, 2024

no repro on Windows. maybe this is macOS only CudaText bug?

cudatext_cXbIQ8mWbB.mp4

@veksha

This comment was marked as outdated.

@veksha
Copy link
Owner

veksha commented Jan 9, 2024

reproduced on macOS vm.
this on macOS will first rename current tab title and then creates new tab (BUG?)

from cudatext_cmd import *; ed.cmd(cmd_FileNew); ed.set_prop(PROP_TAB_TITLE, "Diff: ...")

but on Windows/Linux: new tab is created and then renamed.
@Alexey-T

@Alexey-T
Copy link

Alexey-T commented Jan 9, 2024

What is bug repro?
I run in console:

from cudatext_cmd import *; ed.cmd(cmd_FileNew); ed.set_prop(PROP_TAB_TITLE, "Diff: ...")

on Linux I see that new tab has title 'Diff...'. what is bad?

@veksha
Copy link
Owner

veksha commented Jan 9, 2024

bug is on macOS, not on Linux.

@veksha
Copy link
Owner

veksha commented Jan 9, 2024

workaround attempt: 398adf3
please pull latest changes and try again, @JairoMartinezA
now diff action must not use current tab.

If you still have "Diff: ..." this is because it is saved inside "history files.json" as "cap" key.
the workaround must work: diff output will use new tab instead of current.

@Alexey-T question: how can we easily forget tab title saved in "cap" key in "history files.json"? clearing Recent Files command will do it, but it also clears Bookmarks! (is it OK? i don't think so)

@Alexey-T
Copy link

Alexey-T commented Jan 9, 2024

either clear tab title via API, or clear the history. yes, it clears bookmarks.

@veksha
Copy link
Owner

veksha commented Jan 9, 2024

then maybe it should be renamed to "Clear recent files and bookmarks"?
or be split into two commands.

@Alexey-T
Copy link

Alexey-T commented Jan 9, 2024

code of clearing is doing simple deletion of file. not easy to change it to delete only some JSON keys. so i will rename to 'clear recent files+bookmarks'.

@veksha
Copy link
Owner

veksha commented Jan 9, 2024

@JairoMartinezA changed workaround to use timer instead of app_idle(True). I tested - all ok. can you test?

@veksha
Copy link
Owner

veksha commented Jan 9, 2024

why using ed.cmd(cmds.cmd_FileNew) if we have file_open('') ? pls test the latter. if not ok, i will try to fix it

@Alexey-T , changed and it works good on macOS! (updated both of my plugins with this change)

PS: why it works differently? file_open and cmd_FileNew

@Alexey-T
Copy link

Alexey-T commented Jan 9, 2024

cmd_FileNew runs this

formmain.pas

procedure TfmMain.DoFileNew;
var
  Frame: TEditorFrame;
begin
  Frame:= DoFileOpen('', '');
  DoApplyNewdocLexer(Frame);

  //ProcessMsg is only needed for macOS (so plugin API will update 'ed' to new tab),
  //but no harm for other OSes
  Application.ProcessMessages;
end;

here I added ProcessMessages- better?

Alexey-T added a commit to Alexey-T/CudaText that referenced this issue Jan 9, 2024
@veksha
Copy link
Owner

veksha commented Jan 9, 2024

i will test later.

@JairoMartinezA
Copy link
Author

JairoMartinezA commented Jan 9, 2024

Excuse me Team, timezones differences of the flat earth 😸 I am getting up of bed.

Testing.


UPDATE
@veksha I had to "clean" history files.json but with last changes all is working well.

@veksha
Copy link
Owner

veksha commented Jan 9, 2024

here I added ProcessMessages- better?

@Alexey-T

file_open('') - works
ed.cmd(cmds.cmd_FileNew) - still doesn't work

@Alexey-T
Copy link

Alexey-T commented Jan 9, 2024

let's try here:

app/proc_cmd.pas, comment cmd_FileNew:

function IsCommandNeedTimer(Cmd: integer): boolean;
begin
  if Cmd<cmdFirstAppCommand then exit(false);
  if Cmd>cmdLastAppCommand then exit(false);

  case Cmd of
    cmdFirstLexerCommand..cmdLastLexerCommand,
    cmdFirstPluginCommand..cmdLastPluginCommand,
    cmdFirstPluginSubCommand..cmdLastPluginSubCommand,
    cmdFirstFileCommand..cmdLastFileCommand,
    cmdFirstRecentCommand..cmdLastRecentCommand:
      Result:= true;

    //cmd_FileNew, //don't need timer
    cmd_FileNewMenu, 

Alexey-T added a commit to Alexey-T/CudaText that referenced this issue Jan 9, 2024
@Alexey-T
Copy link

Alexey-T commented Jan 9, 2024

I pushed this new fix to git. pull + try it.

@veksha
Copy link
Owner

veksha commented Jan 10, 2024

yes, this is it!

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

3 participants