-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[Monaco] Make minimap toggleable #33742
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,13 +48,13 @@ public static HashSet<string> GetExtensions() | |
/// <summary> | ||
/// Prepares temp html for the previewing | ||
/// </summary> | ||
public static string PreviewTempFile(string fileText, string extension, string tempFolder, bool tryFormat, bool wrapText, bool stickyScroll, int fontSize) | ||
public static string PreviewTempFile(string fileText, string extension, string tempFolder, bool tryFormat, bool wrapText, bool stickyScroll, int fontSize, bool minimap) | ||
{ | ||
// TODO: check if file is too big, add MaxFileSize to settings | ||
return InitializeIndexFileAndSelectedFile(fileText, extension, tempFolder, tryFormat, wrapText, stickyScroll, fontSize); | ||
return InitializeIndexFileAndSelectedFile(fileText, extension, tempFolder, tryFormat, wrapText, stickyScroll, fontSize, minimap); | ||
} | ||
|
||
private static string InitializeIndexFileAndSelectedFile(string fileContent, string extension, string tempFolder, bool tryFormat, bool wrapText, bool stickyScroll, int fontSize) | ||
private static string InitializeIndexFileAndSelectedFile(string fileContent, string extension, string tempFolder, bool tryFormat, bool wrapText, bool stickyScroll, int fontSize, bool minimap) | ||
{ | ||
string vsCodeLangSet = Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.GetLanguage(extension); | ||
|
||
|
@@ -81,13 +81,14 @@ private static string InitializeIndexFileAndSelectedFile(string fileContent, str | |
string html = Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.ReadIndexHtml(); | ||
|
||
html = html.Replace("[[PT_LANG]]", vsCodeLangSet, StringComparison.InvariantCulture); | ||
html = html.Replace("[[PT_WRAP]]", wrapText ? "1" : "0", StringComparison.InvariantCulture); | ||
html = html.Replace("[[PT_CONTEXTMENU]]", "0", StringComparison.InvariantCulture); | ||
html = html.Replace("[[PT_STICKY_SCROLL]]", stickyScroll ? "1" : "0", StringComparison.InvariantCulture); | ||
html = html.Replace("[[PT_WRAP]]", wrapText ? "true" : "false", StringComparison.InvariantCulture); | ||
html = html.Replace("[[PT_CONTEXTMENU]]", "false", StringComparison.InvariantCulture); | ||
html = html.Replace("[[PT_STICKY_SCROLL]]", stickyScroll ? "true" : "false", StringComparison.InvariantCulture); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once again here, why the change of logic? I'm not saying it's wrong, but I'd like to understand the reasoning behind it. |
||
html = html.Replace("[[PT_THEME]]", theme, StringComparison.InvariantCulture); | ||
html = html.Replace("[[PT_FONT_SIZE]]", fontSize.ToString(CultureInfo.InvariantCulture), StringComparison.InvariantCulture); | ||
html = html.Replace("[[PT_CODE]]", base64FileCode, StringComparison.InvariantCulture); | ||
html = html.Replace("[[PT_URL]]", Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName, StringComparison.InvariantCulture); | ||
html = html.Replace("[[PT_MINIMAP]]", minimap ? "true" : "false", StringComparison.InvariantCulture); | ||
|
||
string filename = tempFolder + "\\" + Guid.NewGuid().ToString() + ".html"; | ||
File.WriteAllText(filename, html); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,13 +396,14 @@ private void InitializeIndexFileAndSelectedFile(string filePath) | |
// prepping index html to load in | ||
_html = FilePreviewCommon.MonacoHelper.ReadIndexHtml(); | ||
_html = _html.Replace("[[PT_LANG]]", _vsCodeLangSet, StringComparison.InvariantCulture); | ||
_html = _html.Replace("[[PT_WRAP]]", _settings.Wrap ? "1" : "0", StringComparison.InvariantCulture); | ||
_html = _html.Replace("[[PT_CONTEXTMENU]]", "1", StringComparison.InvariantCulture); | ||
_html = _html.Replace("[[PT_WRAP]]", _settings.Wrap ? "true" : "false", StringComparison.InvariantCulture); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic changed here, as asked on other comments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @jaimecbernardo, thanks for the review. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the info. I think that makes sense. I don't think that brings any issue. I'll give it a test soon to check if everything's OK ;) |
||
_html = _html.Replace("[[PT_CONTEXTMENU]]", "true", StringComparison.InvariantCulture); | ||
_html = _html.Replace("[[PT_THEME]]", Settings.GetTheme(), StringComparison.InvariantCulture); | ||
_html = _html.Replace("[[PT_STICKY_SCROLL]]", _settings.StickyScroll ? "1" : "0", StringComparison.InvariantCulture); | ||
_html = _html.Replace("[[PT_STICKY_SCROLL]]", _settings.StickyScroll ? "true" : "false", StringComparison.InvariantCulture); | ||
_html = _html.Replace("[[PT_FONT_SIZE]]", _settings.FontSize.ToString(CultureInfo.InvariantCulture), StringComparison.InvariantCulture); | ||
_html = _html.Replace("[[PT_CODE]]", _base64FileCode, StringComparison.InvariantCulture); | ||
_html = _html.Replace("[[PT_URL]]", FilePreviewCommon.MonacoHelper.VirtualHostName, StringComparison.InvariantCulture); | ||
_html = _html.Replace("[[PT_MINIMAP]]", _settings.Minimap ? "true" : "false", StringComparison.InvariantCulture); | ||
} | ||
|
||
private async void DownloadLink_Click(object sender, EventArgs e) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these equivalent in JavaScript? Why the change from from ternary to this?