slynch8 / 10x

10x IDE/Editor
189 stars 33 forks source link

Auto Indent stopped work on C files #1363

Closed Muzza closed 1 year ago

Muzza commented 1 year ago

Indenting in .c files has stopped working, See example:

void Something( void )
{ // press return here - indents if file is .cpp but not if file is .c

My settings file:

# The main UI font for 10X. Can be the font name, the name of the ttf file in a system fonts folder or the full path to a ttf file.
UIFont:                                   LiberationSans-Regular

# Use 'Horizontal' for standard sub-pixel rendering, 'None' to disable.
# Use VerticalLeft if you have your monitor orientated vertically on its
# left side, and VerticalRight if orientated on the right side.
# Valid values: None, Horizontal, VerticalLeft, VerticalRight
FontSubPixelRenderingMode:                Horizontal

# Gamma value for font rendering
FontGamma:                                2.2

# The main UI Scale. Set to 1 for 100% scaling, 1.5 for 150% etc. Set to 'auto' to use the OS scale.
# Valid values: float, auto
UIScale:                                  auto

# The font for all text editor windows. Can be the font name, the name of the ttf file in a system fonts folder or the full path to a ttf file.
EditorFont:                               JetBrainsMonoNL-Medium

# The font size for all text editor windows
EditorFontSize:                           11

# Extra spacing between lines
VerticalLineGap:                          1

# Hide the main menu when not in use. Mouse Over to make visible.
HideMainMenu:                             true

# The current colour scheme for all UI elements. Can be 'default'
ColourScheme:                             VS+VAX

# How often to backup unsaved files (ms)
FileBackupFrequency:                      5000

# Default scripts that 10x has installed to the appdata\10x\PythonScripts path
Python.Installed Scripts:                 Example.py,Snippets.py,RunDebugger.py,FormatFile.py,UE4CompileSingleFile.py,FormattingTests.py,KeyMappingExample.py,ClangFormat.py

# Whether lines should be indented with tabs or spaces
# Valid values: Tabs, Spaces
IndentMode:                               Tabs

# Width of a tab in chars
TabWidth:                                 4

# Path of the Visual Studio VsDevCmd.bat or vcvars64.bat batch file to use for setting the Visual Studio build environment. Restart 10X after changing this value. Set to 'auto' to let 10x try and find the path
VisualStudioEnvBat:                       C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/Tools/VsDevCmd.bat

# Enable VSync
VSync:                                    true

# Scroll bar mode for code text editor panels
# Valid values: Standard, Map
# Valid values: Standard, Map
ScrollBarMode:                            Standard

# Crash dump mode. Restart 10x for this to take effect
# Valid values: Mini, MiniWithHeap, Full
# Valid values: Mini, MiniWithHeap, Full
CrashDumpMode:                            MiniWithHeap

# Number of lines scroll wheel scrolls
MouseWheelScrollStep:                     3

# Control+click in text editor to go to definition of symbol. Otherwise just selects word.
ControlClickGotoDefinition:               true

# Setting to true sleeps the app when idle instead of calling Present. The app is considered idle when nothing on screen changes and there is no user input. Calling nothing but present still uses a small <1% of CPU time, setting this will get it to 0%. However, this can cause issues with G-Sync. A better solution to the G-Sync problem is to turn off G-Sync for 10x in the NVIDIA display settings.
DisablePresentWhenIdle:                   false

# File wildcards for files that should automatically open in column 0. Separated by commas.
Column0Presets:                           *.c,*.cc,*.cpp,*.c++,*.cp,*.cxx

# File wildcards for files that should automatically open in column 1. Separated by commas.
Column1Presets:                           *.h,*.hh,*.hpp,*.h++,*.hp,*.hxx,*

# File wildcards for files that should automatically open in column 2. Separated by commas.
Column2Presets:                           *.bat,*.py

# Show line numbers (true, false)
ShowLineNumbers:                          true

# Margin width
MarginWidth:                              20

# Update the line indents after a paste
UpdateIndentsOnPaste:                     false

# Auto-indent new lines
AutoIndent:                               true

# Highlight all instances of the current symbol
HighlightCurrentSymbol:                   false

# Highlight all instances of the current word
HighlightCurrentWord:                     true

# Highlight all instances of the currently selected word
HighlightSelectedWord:                    true

# Ctrl+tab switch file mode. Can be set to all files or restricted to files open in the current panel
# Valid values: All, Panel
# Valid values: All, Panel
SwitchFileMode:                           Panel

# true to make Toggle Comment command use // line comments instead of /* */
CommentBlockUsesLineComments:             true

# true to make the Comment command move to the next line on single line comments
CommentBlockIncrementLine:                false

# When creating a new line add tabs or spaces to the current indentation depth
ExtendEmptyLines:                         false

# The width of the map scroll bar
MapScrollBarWidth:                        60

# Typing an open bracket/brace char ((,{,[) with selected text will enclose the selection with that bracket/brace
BracketSelectedText:                      false

# Open the last workspace opened when starting 10x
OpenLastWorkspaceOnStartup:               true

# The maximum number of cores to use, -1 to use SystemCoreCount*0.8 (requires restart)
MaxCoreCount:                             -1

# When auto completing a function add the ( bracket and the ) bracket if it has no args
AutoAddFunctionBrackets:                  false

# Hide items with a low match score behind the 'more...' item
AutoCompleteHideLowMatch:                 true

# Show whitespace
ShowWhitespace:                           true

# Show indent lines
ShowIndentGuideLines:                     true

# Enable verbose logging to the .log file
VerboseLogging:                           false

# Eanble drag-drop and drag-reorder in the workspace tree
EnableWorkspaceTreeDragDrop:              true

# Sync breakpoints and current config with Visual Studio
VisualStudioSync:                         false

# The internet search engine command. Search word will be appended to this command.
InternetSearchCommand:                    https://www.google.com/search?q=

# Autosave 10x workspace files as soon as changes are made
AutosaveWorkspace:                        false

# If true then new untitled files will automatically be saved on exit and restored on restart
RestoreUnsavedFiles:                      false

# Take the name of the file from the first word typed
AutoNameUntitledFiles:                    false

# Open the previously opened files on startup when no workspace is open
RememberOpenFiles:                        false

# Allow submitting of first item in list with tab even if no item is selected
SubmitFirstAutocomplete:                  true

# If enabled, left/right cursor keys move between text boxes and buttons in the find and find/replace panels
FindPanelCursorKeys:                      true

# Close the find panel when the Enterkey is pressed
CloseFindPanelOnEnter:                    false

# Vertical mouse wheel sensitivity
VerticalMouseWheelSensitivity:            1

# Horizontal mouse wheel sensitivity
HorizontalMouseWheelSensitivity:          1

# Reopen a file in the current panel even if it already open in a different panel
ReopenFileInCurrentPanel:                 false

# Build before starting debugging using the StartDebugging command
BuildBeforeStartDebugging:                true

# Build before running the exe
BuildBeforeRun:                           true

# Comma separated list of columns for ruler lines
VerticalRulers:                           

# true to make the Enter key submit autocomplete
SubmitAutocompleteOnEnter:                true

# cursor blink rate. Time in ms between blinks. Can be set to auto to use the OS blick rate. Set to 0 to disable.
CursorBlinkRate:                          auto

# Show the main app menu when the mouse hovers over
ShowMainMenuOnMouseHover:                 true

# How to show the workspace in the title bar if the menu is hidden (None, Name, Path)
# Valid values: None, Name, Path
WorkspaceTextInTitleBar:                  Name

# How to set the initial text when the find text panel is shown. Current means use the current word, Selected means use the current selection. Values: (None, Current, Selection)
# Valid values: None, Current, Selection
FindTextInitialValue:                     Current

# How to set the initial text when the find/replace text panel is shown. Current means use the current word, Selected means use the current selection. Values: (None, Current, Selection)
# Valid values: None, Current, Selection
ReplaceTextInitialValue:                  Selection

# Automatically detect the indentation mode (tabs or spaces) when the files is opened. If inconclusive defaults to the IndentMode setting
AutoDetectIndentMode:                     false

# The main UI font size for 10X. It's usually better to change the UI.Scale which also scales the font size.
UI.Font Size:                             9

# Delay before the drag-drop dock target panel appears (in ms)
UI.DragDropDockDelay:                     200

# Maximum time in ms for two mouse clicks to be considered a double click
UI.MouseDoubleClickTime:                  500

# True to scroll at 60fps
Editor.Fast Scroll:                       true

# The key repeat rate increases the longer the key is held down. Set to zero to disable.
Editor.Key Repeat Acceleration:           0

# Time in ms after key is held before it repeats
UI.InitialKeyRepeatDelay:                 500

# Time in ms between key repeats. Set to multiple of 16.6666ms for smooth repeats at 60fps
UI.KeyRepeatDelay:                        33.333333

# Path mode for the Search panel results
# Valid values: Full, Relative, Filename, FolderAndFile
Search.PathMode:                          FolderAndFile

# Search will search files with these extensions
Search.Extensions:                        .asm, .bat, .c, .cc, .cpp, .cs, .css, .csv, .cxx, .def, .disco, .dtd, .fx, .h, .hh, .hpp, .hlsl, .htm, .html, .hxx, .idl, .inc, .inl, .java, .js, .l, .ll, .lnx, .log, .mk, .pl, .pmk, .ps, .py, .s, .sh, .src, .srf, .tlh, .tli, .txt, .vb, .vsh, .wsdl, .xaml, .xml, .xsd, .xsl, .xslt, .y, .psh, .fsh, .sh, .shader, .vsct, .resx, .wxs, .php, .vsixmanifest, .uc, .sql, .webconfig, .aspx, .lua, .cshtml, .mm, .m, .as

# Comma separated list of wildcards for files to exclude
Search.ExcludeList:                       */sqlite/*,*/sqlite/*

# The maximum file size that Search will index
Search.MaxFileSize:                       10485760

# Use the current word as the initial search text when opening the Search panel
Search.SerchCurrentWord:                  true

# Spaces are treated as * wildcards when matching files
Search.SpacesAsWildcardsForFindFile:      true

# Search will stop searching after this many results have been found
Search.MaxResults:                        10000

# Sort the file results by how often they have been opened
Search.SortOpenFilesByOpenFrequency:      false

# Comma separated list of paths. The parser will parse all files found in these directories. End with * to add files recursively.
AdditionalIncludePaths:                     

# Use the current word as the initial search text when opening the Search panel
Search.SearchCurrentWord:                 true

# Automatically fix . and -> depending if the variable is a pointer
AutoFixIndirection:                       false

# Automatically add a close brace after typing an open brace
AutoAddCloseBrace:                        false

# Automatically format statement or block when typing a ; or }
AutoFormat:                               false

# Dismiss the autocomplete when the typed text matches one of these comma separated strings
ExactMatchAutoComplete:                   else,endif,once

# true to indent case statements inside switch case block
IndentCaseStatements:                     false

# Comma separated list of paths to exclude (supports wildcards). Clear out cache for it to take effect.
ParserExcludeFilters:                     */sqlite/*,*/sqlite/*

# Update the current block indentation when a close brace is typed
UpdateIndentsOnCloseBrace:                false

# When autcompleting functions submit the autocomplete by typing (
SubmitAutocompleteOnOpenBracket:          false

# If true, goto definition on function calls will go to the function implementation instead of the declaration
GotoFunctionImplementation:               false

# Automatically add a close bracket after typing an open bracket
AutoAddCloseBracket:                      false

# When pressing Enter between {} braces move the braces to new lines
FormatBracesOnEnterSplit:                 false

# Typing /** will add a */, Enter will add a new line starting with *
AutoFormatBlockComments:                  false

# Automatically add a close brace and format the braces
AutoAddCloseBraceAndFormat:               false

# If true the open brace will be moved to the next line on auto-foramt
OpenBraceOnNewLine:                       true

# true to enable autocomplete to automatically show as you type
Autocomplete:                             true

# if true, '#if SOMETHING' will resolve to '#if 1' if SOMETHING isn't defined. Reopen the workspace and reparse for this to take effect.
TreatUndefinedDefinesAsTrue:              false

# New comment lines will be started with * when AutoFormatBlockComments is enabled
AutoFormatBlockCommentsNewLines:          true

# Comma separated list of extensions for the C++ parser to parse. Requires a clean reparse to take effect.
ParserExtensions:                         .c,.cc,.cpp,.c++,.cp,.cxx,.h,.hh,.hpp,.h++,.hp,.hxx,.inl.vert,.frag,.comp,.geom,.eval,.cont,.glsl,.hlsl,.hlsli,.usf,.ush,.cg,.cs,.ixx

# Brightness of defined out code
DefinedOutBrightness:                     0.75

# Enable the Vim style editing
Vim:                                      false

# How to display the cursor (caret) in the text editor. Values: (Line, Block, Underscore)
# Valid values: Line, Block, Underscore, HalfBlock
CursorMode:                               Line

# Whether lines should be indented with tabs or spaces
PythonIndentMode:                         Tabs

# whether to toggle the main menu on the alt key
ToggleMainMenuOnAlt:                      true

# Controls the column in which a file is opened for Goto symbol definition
GotoDefColumn:                            default

# Always centre floating panels horizontally
CentreFloatingPanelsHorz:                 true

# Always centre floating panels vertically
CentreFloatingPanelsVert:                 true

# Colour undefined keywords using the Language.UndefinedKeyword colour scheme colour
ColourUndefinedKeywords:                  true

# Show Line Endings
ShowLineEndings:                          false

# true to enable autocomplete in comments
AutocompleteInComments:                   false

# The maximum number of tabs to keep open
MaxOpenTabs:                              20

# whether to toggle the main menu on the alt key
ToggleMainMenuOnAlt:                      true

# Controls the column in which a file is opened for Goto symbol definition and Goto Build Error
GotoDefColumn:                            default

# Always centre floating panels horizontally
CentreFloatingPanelsHorz:                 true

# Always centre floating panels vertically
CentreFloatingPanelsVert:                 true

# Colour undefined keywords using the Language.UndefinedKeyword colour scheme colour
ColourUndefinedKeywords:                  false

# The maximum number of tabs to keep open
MaxOpenTabs:                              20

# The default WordWrap setting when opening files
WordWrap:                                 false

# Show the collapse expand margin (true, false)
ShowCollapseRegionMargin:                 false

# Use backslashes in paths
BackslashPaths:                           true

# Align function arguments lines to the function open bracket
BracketAlignFunctionArgs:                 true

# Align conditional lines to the open bracket
BracketAlignConditionals:                 false

# Align lines in assignment statements to equals char
AlignToEquals:                            false

# Highlight the current find text in the scroll bar
HighlightFindTextInScrollBar:             true

# Highlight the currently selected word in the scroll bar
HighlightSelectedWordInScrollBar:         false

# Size of the scroll bar highlights
ScrollBarHighlightSize:                   1.0

# Typedefs and using aliases will be resolved in GotoSymbolDefintion
GotoDefResolvesTypedefs:                  false

# Stop the debugger when a full build starts
StopDebuggingOnBuild:                     false

# If the file hasn't been opened before open it in the currently active panel
OpenFileInActivePanel:                    true

# Remember the panel position of the file when it is closed
RememberFilePanelPos:                     false

# Width of the line markers (bookmarks, breakpoints etc) in the margin as a ratio of the line height
LineMarkerWidth:                          16

# True to toggle breakpoints in the margin with the mouse
ToggleBreakpointsWithMouse:               true

# True to enable zooming the font with the control + mouse wheel
MouseWheelZoom:                           true

# True to open files in the column specified by the Column0Files, Column1Files, Column2Files settings
UseColumnPresets:                         false
slynch8 commented 1 year ago

Can you check the file is in the workspace? The indenting relies on the parser and the parser only parses files in the workspace

slynch8 commented 1 year ago

I've added this task to parse files that are not in the workspace https://github.com/slynch8/10x/issues/1367

Muzza commented 1 year ago

The file was in the workspace (a VS workspace, I was compiling it). So far today it has not happened. Either just restarting 10x, or possibly the cache files being deleted fixed it (Separate issue but I still have to regularly delete cache files or I get all sorts of parsing and search errors).

However, I do notice that Auto Indent has stopped working in .inl files too. The background colour of the file is different, which normally occurs when the file is not in the workspace, but this one is.

If I create a folder with a .c and .inl and then use 10x OpenFolder, I get the same thing. The .inl file has a different background colour in the text editor, and auto indent does not work.

slynch8 commented 1 year ago

I just noticed you have an error in your ParserExtensions setting, there is no comma after the .inl setting. I think this was a bug that went in a while ago although I did automatically fix it in one of the updates.

I'm not sure what would cause the .c issue though. I've tried it with your settings file and couldn't get it. If it happens again can you use the ListworkspaceFiles and CppParser.ListWorkspaceFiles commands and check that the files are in the workspace files lists. It sounds like the parser doesn't know about the file for some reason.

Also, you shouldn't ever have to delete the cache anymore. You can use the ReparseFile and ReparseAll commands from the ctrl+shift+X command panel or the menu.

But ideally you shouldn't ever have to do a manual reparse. I know it's really tricky to track these things down, but if you notice what sort of edit you are doing before it goes wrong then let me know. I need to track these issues down as a high priority - thanks.

Muzza commented 1 year ago

I've not seen the .c issue again, and the .inl was fixed in the settings file. As for clearing the cache, this has always been an issue for me. Autocomplete will start degrading - giving terrible suggestions. Go to symbol will stop working. Sometimes I've had duplicate results appearing in the search panel, but some in grey (this one not recently though). Issue #554 means that autocomplete/go to symbol don't always work for me anyway, so often I assume it is just that until things get so bad that I try deleting the cache, and find everything generally improves. I've no idea what causes it - it just seems to happen over time as I edit files. Anyway this issue can be closed.

slynch8 commented 1 year ago

I'm sorry to hear that. It's usually very easy to fix once I find out what's causing it. It's usually because it's not re-parsing all the lines that it should be after an edit. I fixed a load of these bugs a while back, it was often things like it not parsing enough lines after typing an open and then a close brace, or adding a class just above an existing class, things like that. I'll keep a lookout for these problems.