microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.19k stars 28.55k forks source link

Commented Function Not Able To Collapse #136304

Closed zohaibmalik994 closed 2 years ago

zohaibmalik994 commented 2 years ago

Issue Type: Bug

I have been facing this issue and reported it before. But the issue was closed without any fix but vague clarification. The main issue is whenever I comment out a code of block, I am not able to collapse it and have to go through this long block each time navigating the code. That's so weird. I wish it could be possible to collapse that as well or at least there could be an option to collapse the code manually with selection. Thanks! image

VS Code version: Code 1.61.2 (6cba118ac49a1b88332f312a8f67186f7f3c1643, 2021-10-19T14:57:20.575Z) OS version: Windows_NT x64 10.0.19043 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM)2 Quad CPU Q9650 @ 3.00GHz (4 x 3000)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: unavailable_off
opengl: enabled_on
rasterization: unavailable_off
skia_renderer: enabled_on
video_decode: unavailable_off
vulkan: disabled_off
webgl: enabled
webgl2: unavailable_off| |Load (avg)|undefined| |Memory (System)|5.87GB (0.52GB free)| |Process Argv|--crash-reporter-id ced21870-82c3-4a0c-8d37-f749c37e0e4f| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythontb:30283811 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 pythonvsuse255:30340121 vscod805:30301674 pythonvspyt200:30340761 binariesv615:30325510 vsccppwtct:30382698 bridge0708:30335490 pygetstartedt3:30385195 dockerwalkthru:30377721 bridge0723:30353136 pythonrunftest32:30373476 pythonf5test824:30373475 javagetstartedt:30391933 pythonvspyt187:30373474 vsqsis400:30386382 vsaa593cf:30376535 vssld246:30386377 ```
aeschli commented 2 years ago

What is the language mode? Can you attach the sample code?

zohaibmalik994 commented 2 years ago

Sure @aeschli , I am sharing the file with code. Kindly have a look. (This is random code snippets picked from the working code.

I have selected "JavaScript" but it changes to "JavaScript React". Not sure if there is any difference and it might be due to the file extension ".jsx" which actually is a script format for Adobe programs.

But my main issue is that you can check the (var res; and btnSettings.onClick function) has no collapse option. I have attached the screenshot but you can check the code (in zip file) for more details as screenshots do not contain all the code.

Thanks!

image image

collapse-issue-code.zip

aeschli commented 2 years ago

Thanks for sharing the file. I can reproduce. No folding region for the comment or the multi-line string. Assigning to TypeScript.

mjbvz commented 2 years ago

Please share the text of the code along with screenshots

mjbvz commented 2 years ago

Ah actually there's a zip tucked away at the end. Relevant code:

```js { function myScript(thisObj) { function myScript_buildUI(thisObj) { var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "AE Shapes Temoer", undefined, { resizeable: true, closeButton: true, spacing: 0, margins: 0 }); var res = "Group {orientation: 'column', alignment: ['fill', 'fill'], preferredSize: [128, 64],\ groupName: Group{orientation:'column',alignment: 'fill', \ nameCheckbox: Checkbox{text:'Use Default Name', alignment: 'left',},\ nameField: EditText{text:'', alignment: 'fill'},\ groupTemoType: Group{orientation:'row', alignment:'left',\ TemoMethodText: StaticText{text:'Temo Method'},\ groupBButton1: Group{orientation: 'stack', alignChildren: '[center,center]',\ image1SelectedState1: Image{},\ image1IdleState1: Image{},\ buttonTemoSpine: IconButton{properties:{ style: 'toolbutton' }},\ },\ groupBButton2: Group{orientation: 'stack', alignChildren: '[center,center]',\ image2SelectedState1: Image{},\ image2IdleState1: Image{},\ buttonTemoDirect: IconButton{properties:{ style: 'toolbutton' }},\ },\ groupCreateBButtons: Group{orientation: 'row', alignment: 'fill',\ buttonCreateB: Button{text:'Create Temo', alignment: ['fill', 'fill']},\ groupRefreshTemo: Group{orientation: 'stack', alignChildren: '[center,center]',\ refreshButtonBox: Image{},\ buttonRefreshB: IconButton{properties:{ style: 'toolbutton' }},\ },\ buttonUpdateB: Button{text:'Update Temo', alignment: ['fill', 'fill']},\ groupPathStatuses: Group{orientation: 'column', \ textPathStatuses: StaticText{text:'Path Statuses'},\ groupPathStatusesBtns: Group{orientation: 'row',\ groupOpenPaths: Group{orientation: 'stack', alignChildren: '[center,center]',\ bgBox3: Image{},\ buttonOpenPaths: IconButton{properties:{ style: 'toolbutton' }},\ },\ groupClosePaths: Group{orientation: 'stack', alignChildren: '[center,center]',\ bgBox4: Image{},\ buttonClosePaths: IconButton{properties:{ style: 'toolbutton' }},\ },\ },\ groupOtherOptions: Group{orientation: 'column', \ textOtherOptions: StaticText{text:'Other Options'},\ groupOtherOptionsBtns: Group{orientation: 'row',\ groupReverseOrder: Group{orientation: 'stack', alignChildren: '[center,center]',\ bgBox9: Image{},\ buttonReverseOrder: IconButton{properties:{ style: 'toolbutton' }},\ },\ groupBakeEverything: Group{orientation: 'stack', alignChildren: '[center,center]',\ bgBox10: Image{},\ buttonBakeEverything: IconButton{properties:{ style: 'toolbutton' }},\ },\ },\ }"; myPanel.grp = myPanel.add(res); /* btnSettings.onClick = function () { //eval("@JSXBIN@ES@2.0@MyBbyBn0ANJAnASzGjXjJjOjEjPjXByBEjzGiXjJjOjEjPjXCfREFeHjQjBjMjFjUjUjFFePiGjMjPjBjUjJjOjHhAiTjDjSjJjQjUjzJjVjOjEjFjGjJjOjFjEDfWzGiPjCjKjFjDjUEBzLjDjMjPjTjFiCjVjUjUjPjOFFctftnftJBnABXzLjPjSjJjFjOjUjBjUjJjPjOGfVBfyBneGjDjPjMjVjNjOfJDnASzIjHjSjPjVjQiPjOjFHyBEXzDjBjEjEIfVBfyBRDFeFjHjSjPjVjQjDfFeIjHjSjPjVjQiPjOjFffnftJEnABXGfVHfyBneDjSjPjXfJFnASzQjDjSjFjBjUjFiDjPjNjQiCjVjUjUjPjOJyBEXIfVHfyBRDFeGjCjVjUjUjPjOjDfFeLiDjSjFjBjUjFhAiDjPjNjQffnftJHnASzIjHjSjPjVjQiUjXjPKyBEXIfVBfyBRDFeFjQjBjOjFjMjDfFeAffnftJInABXGfVKfyBneDjSjPjXfJJnASzGjNjZiUjFjYjULyBEXIfVKfyBRDFeKjTjUjBjUjJjDjUjFjYjUjDfFeYiKjVjTjUhAjTjPjNjFhAjPjUjIjFjShAiViJhAjTjUjVjGjGffnftJLnASzKjHjSjPjVjQiUjIjSjFjFMyBEXIfVBfyBRDFeFjHjSjPjVjQjDfFeKjHjSjPjVjQiUjIjSjFjFffnftJMnABXGfVMfyBneDjSjPjXfJNnASFyBEXIfVMfyBRDFeGjCjVjUjUjPjOjDfFeFiDjMjPjTjFffnftJPnAEXzGjDjFjOjUjFjSNfVBfyBnfJQnAEXzEjTjIjPjXOfVBfyBnfAHF4G0AiAH4B0AiAJ4C0AiAM4F0AiAK4D0AiAL4E0AiAB40BiAAHAzAPByB"); var builder = createDialog(); builder.show(); function createDialog() { var dlg = new Window('dialog', 'Gallery Print Script'); //dlg.frameLocation = [100, 100]; dlg.txtName = dlg.add('edittext', undefined, 'Sample Text'); dlg.txtName.preferredSize = [200, 20]; dlg.btnRun = dlg.add('button', undefined, 'Run'); return dlg; } //hyperlink function demo contactBtn.onClick = function () { var myURL = "mailto:email@domain.com"; openUrl(myURL); function openUrl(url) { if (isWin()) { openUrlWin(url); } else { openUrlMac(url); } function openUrlMac(url) { var command = 'open "' + url + '"'; system.callSystem(command); } function openUrlWin(url) { var command = 'start ' + url; executeWinCommandlineCommand(command); function executeWinCommandlineCommand(command) { var escapedCommand = escapeForWindowsCmd(command); var outerCommand = "cmd /c \"" + escapedCommand + "\""; system.callSystem(outerCommand); } function escapeForWindowsCmd(string) { // put a ^ before every META character that has a special meaning in CMD var metaChars = ['^', '(', ')', '%', '!', '"', '<', '>', '&', '|', '\n']; var prefix = "^"; for (var i = 0; i < metaChars.length; i++) { string = replaceAll(string, metaChars[i], prefix + metaChars[i]); } return string; } function replaceAll(string, search, replace) { return string.split(search).join(replace); } } } function isWin() { return $.os.indexOf("Windows") != -1; } } } */ ///////////////////////////////////////////////////////////////////////////////////////////////////// myPanel.layout.layout(true); myPanel.onResizing = myPanel.onResize = function () { this.layout.resize(); }; return myPanel; } var myScriptPal = myScript_buildUI(thisObj); if (myScriptPal != null && myScriptPal instanceof Window) { myScriptPal.center(); myScriptPal.show(); } } myScript(this); } function initCompItems() { var compItems = { comp: app.project.activeItems, layers: app.project.activeItems.selectedLayers, } } ```
mjbvz commented 2 years ago

Minimal example:

/*
x
*/

console.log(1)
zohaibmalik994 commented 2 years ago

Yes, that's true @mjbvz , I have attached the zip because .jsx file was not supported. I didn't think of sharing the code directly. Sorry for any confusion.

mjbvz commented 2 years ago

Opened https://github.com/microsoft/TypeScript/issues/46666 to track root cause upstream

zohaibmalik994 commented 2 years ago

Also @mjbvz , I have a feature request to have an option to fold/unfold a selection of desired code. It can also fix a lot of such problems in future.