Skip to content

Commit bf49e9c

Browse files
committed
v13.3
1 parent b0eaf49 commit bf49e9c

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

ghost_terminal.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#define floop while(1)
3232

33-
#define GT_VAR_STR "13.2"
33+
#define GT_VAR_STR "13.3"
3434

3535
using namespace SSTP_link_n;
3636
using namespace std;
@@ -421,16 +421,22 @@ class ghost_terminal final: public simple_terminal {
421421
editting_command_t terminal_tab_press(const editting_command_t& command, size_t tab_num) override {
422422
if(!able_tab_press)
423423
return command;
424+
static size_t last_old_insert_index = 0;
425+
if(!tab_num)
426+
last_old_insert_index = command.insert_index;
424427
auto Result = linker.NOTYFY({{L"Event", L"ShioriEcho.TabPress"},
425428
{L"Reference0", command.command},
426429
{L"Reference1", to_wstring(command.insert_index)},
427-
{L"Reference2", to_wstring(tab_num)}});
430+
{L"Reference2", to_wstring(tab_num)},
431+
{L"Reference3", to_wstring(last_old_insert_index)}});
428432

429433
editting_command_t Result_command = command;
430434
if(Result.has(L"Command"))
431435
Result_command.command = Result[L"Command"];
432436
if(Result.has(L"InsertIndex"))
433437
Result_command.insert_index = stoull(Result[L"InsertIndex"]);
438+
if(Result.has(L"OldInsertIndex"))
439+
last_old_insert_index = stoull(Result[L"OldInsertIndex"]);
434440
return Result_command;
435441
}
436442
bool terminal_run(const wstring& command) override {
@@ -662,22 +668,17 @@ class ghost_terminal final: public simple_terminal {
662668
string wt_json;
663669
{
664670
HANDLE hFile = CreateFileW(wt_json_path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
665-
if(hFile == INVALID_HANDLE_VALUE) {
666-
err << SET_RED "Can't open file: " SET_CYAN << wt_json_path << RESET_COLOR << endline;
667-
exit(1);
668-
}
669-
DWORD dwFileSize = GetFileSize(hFile, nullptr);
670-
if(dwFileSize == INVALID_FILE_SIZE) {
671-
err << SET_RED "Can't get file size: " SET_CYAN << wt_json_path << RESET_COLOR << endline;
672-
exit(1);
673-
}
674-
wt_json.resize(dwFileSize);
675-
DWORD dwRead;
676-
if(!ReadFile(hFile, wt_json.data(), dwFileSize, &dwRead, nullptr)) {
677-
err << SET_RED "Can't read file: " SET_CYAN << wt_json_path << RESET_COLOR << endline;
678-
exit(1);
671+
if(hFile != INVALID_HANDLE_VALUE) {
672+
const DWORD dwFileSize = GetFileSize(hFile, nullptr);
673+
if(dwFileSize != INVALID_FILE_SIZE) {
674+
wt_json.resize(dwFileSize);
675+
DWORD dwRead;
676+
if(!ReadFile(hFile, wt_json.data(), dwFileSize, &dwRead, nullptr)) {
677+
err << SET_RED "Can't read file: " SET_CYAN << wt_json_path << SET_RED ", overwriting it." RESET_COLOR << endline;
678+
}
679+
}
680+
CloseHandle(hFile);
679681
}
680-
CloseHandle(hFile);
681682
}
682683
{
683684
wstring start_command;

0 commit comments

Comments
 (0)