Skip to content

Commit

Permalink
Windows: when Sublime Text is associated with Lua files, Ctrl+Shift+O…
Browse files Browse the repository at this point in the history
… would also open the project
  • Loading branch information
Shchvova committed Jun 8, 2020
1 parent 658644d commit 822337c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions platform/android/resources/build.xml
Expand Up @@ -88,8 +88,8 @@
</condition>
<target name="check-gradle-bundle">
<available file="${corona.native.android}/resource/android-template.zip" property="gradle.bundle.exists"/>
</target>
<target name="setup-gradle-builds" if="gradle.bundle.exists" depends="check-gradle-bundle">
</target>
<target name="setup-gradle-builds" depends="check-gradle-bundle">
<sequential>
<delete dir="${TEMP_DIR}/template"/>
<unzip src="${corona.native.android}/resource/android-template.zip" dest="${TEMP_DIR}" />
Expand Down
2 changes: 1 addition & 1 deletion platform/mac/TextEditorSupport.m
Expand Up @@ -118,7 +118,7 @@ void TextEditorSupport_LaunchTextEditorWithFile(NSString* file_name, NSInteger l
[[NSWorkspace sharedWorkspace] openFile:file_name];
}
}
else if([base_app_name isEqualToString:@"Sublime Text 2.app"] || [base_app_name isEqualToString:@"Sublime Text.app"])
else if([base_app_name isEqualToString:@"Sublime Text 2.app"] || [base_app_name isEqualToString:@"Sublime Text.app"] || [base_app_name isEqualToString:@"Sublime Text 3.app"] )
{
// From http://www.sublimetext.com/docs/2/osx_command_line.html

Expand Down
19 changes: 18 additions & 1 deletion platform/windows/Corona.Simulator/SimulatorView.cpp
Expand Up @@ -986,6 +986,7 @@ void CSimulatorView::OnFileOpenInEditor()
ASSOCF_INIT_DEFAULTTOSTAR, ASSOCSTR_EXECUTABLE, _T(".lua"),
NULL, fileAssociation.GetBuffer(MAX_PATH_LENGTH), &fileAssociationLength);
fileAssociation.ReleaseBuffer();
CString fullAssociationPath(fileAssociation);
if (S_OK == result)
{
index = fileAssociation.ReverseFind(_T('\\'));
Expand Down Expand Up @@ -1021,7 +1022,23 @@ void CSimulatorView::OnFileOpenInEditor()
// If Windows doesn't have a valid file association, then open it with Notepad.
if (hasValidFileAssociation)
{
::ShellExecute(nullptr, _T("open"), GetDocument()->GetPath(), nullptr, nullptr, SW_SHOWNORMAL);
if (fileAssociation == _T("sublime_text.exe")) {
CString fullPath(GetDocument()->GetPath());
index = fullPath.ReverseFind(_T('\\'));
if (index > 0)
{
CString dirPath(fullPath);
dirPath.Delete(index, dirPath.GetLength() - index);
fullPath.Insert(0, _T('"'));
fullPath.Append(_T("\" --add \""));
fullPath.Append(dirPath);
fullPath.Append(_T("\""));
}
::ShellExecute(nullptr, nullptr, fullAssociationPath, fullPath, nullptr, SW_SHOWNORMAL);
}
else {
::ShellExecute(nullptr, _T("open"), GetDocument()->GetPath(), nullptr, nullptr, SW_SHOWNORMAL);
}
WinString appName;
appName.SetTCHAR(fileAssociation);
GetWinProperties()->GetAnalytics()->Log( "open-in-editor", "editor", appName.GetUTF8() );
Expand Down

0 comments on commit 822337c

Please sign in to comment.