Indent Provider
An indent provider enables support for smart indent features when pressing Enter.
The Indent Providers topic talks about indent providers in general and how to register them as a "feature" language service.
The PythonIndentProvider class is the default implementation of an IIndentProvider service for this language.
Feature Summary
Smart Indent
The built-in indent provider will attempt to properly indent lines inside the current block scope.
For instance, pressing Enter after a :
will cause the next line to be indented by one tab stop. Pressing Enter after a statement such as a return
statement will outdent by one tab stop.
Registering with a Syntax Language
Any object that implements IIndentProvider can be associated with a syntax language by registering it as an IIndentProvider service on the language.
The PythonSyntaxLanguage class automatically registers a PythonIndentProvider with itself when it is created, so normally indent providers never need to be set on a Python language unless a custom one is made.
This code creates a custom indent provider (defined in a make-believe CustomPythonIndentProvider
class) and registers it with the syntax language that is already declared in the language
variable:
language.RegisterIndentProvider(new CustomPythonIndentProvider());
Note
The SyntaxLanguageExtensions.RegisterIndentProvider method in the code snippet above is a helper extension method that gets added to ISyntaxLanguage objects when the ActiproSoftware.Text
namespace is imported. See the Service Locator Architecture topic for details on registering and retrieving various service object instances, both via extension methods and generically, as there are some additional requirements for using the extension methods.
Disabling the Functionality
Since this feature is installed as a "feature" service on the language and is installed on PythonSyntaxLanguage by default, it can be disabled by uninstalling the service from the language.