-
Notifications
You must be signed in to change notification settings - Fork 77
Custom formatting of display name #359
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
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 | ||
|---|---|---|---|---|
|
|
@@ -280,6 +280,21 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ | |||
| + "non-directional, like Kakoune.", | ||||
| ], | ||||
| }, | ||||
| activeModeDisplayTextTransform: { | ||||
| "enum": [ | ||||
| "as-is", | ||||
| "uppercase", | ||||
| "lowercase", | ||||
|
|
||||
|
||||
71 marked this conversation as resolved.
Show resolved
Hide resolved
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| import * as vscode from "vscode"; | ||
|
|
||
| import type { Extension } from "./extension"; | ||
| import type { Mode } from "./modes"; | ||
| import { command, commands, Context, Positions, SelectionBehavior, Selections } from "../api"; | ||
| import { extensionName } from "../utils/constants"; | ||
| import { assert } from "../utils/errors"; | ||
| import type { Extension } from "./extension"; | ||
| import type { Mode } from "./modes"; | ||
|
|
||
| /** | ||
| * Dance-specific state related to a single `vscode.TextEditor`. | ||
|
|
@@ -234,14 +234,27 @@ export class PerEditorState implements vscode.Disposable { | |
| public notifyDidBecomeActive() { | ||
| const { editor, mode } = this; | ||
|
|
||
| this.extension.statusBar.activeModeSegment.setContent(mode.name); | ||
| this.extension.statusBar.activeModeSegment.setContent(this._formatDisplayName(mode.name)); | ||
|
|
||
| editor.options.lineNumbers = mode.lineNumbers; | ||
| editor.options.cursorStyle = mode.cursorStyle; | ||
|
|
||
| return vscode.commands.executeCommand("setContext", extensionName + ".mode", mode.name); | ||
| } | ||
|
|
||
| private _formatDisplayName(modeName: string) { | ||
71 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| switch (vscode.workspace.getConfiguration(extensionName) | ||
| .get<string>("activeModeDisplayTextTransform")) { | ||
|
||
| case "uppercase": | ||
| return modeName.toUpperCase(); | ||
| case "lowercase": | ||
| return modeName.toLowerCase(); | ||
| case "as-is": | ||
| default: | ||
| return modeName; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Called when `vscode.window.onDidChangeActiveTextEditor` is triggered with | ||
| * another editor. | ||
|
|
||
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.
This defines
activeModeDisplayTextTransformas a property set on modes, not a global configuration. You need to move this below and name it"dance.activeModeDisplayTextTransform"instead.