Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions package.build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,21 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({
description: "Controls the different modes available in Dance.",
},

"dance.activeModeDisplayTextTransform": {
"enum": [
"as-is",
"uppercase",
"lowercase",
],
"default": "as-is",
"description": "Controls how the active mode is formatted in the status bar.",
"enumDescriptions": [
"Display the name with its original formatting.",
"Convert the name to uppercase.",
"Convert the name to lowercase.",
],
},

"dance.menus": {
type: "object",
scope: "language-overridable",
Expand Down
14 changes: 14 additions & 0 deletions package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions src/state/editors.ts
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`.
Expand Down Expand Up @@ -234,14 +234,26 @@ 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) {
switch (this.extension.activeModeDisplayPreference) {
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.
Expand Down
16 changes: 16 additions & 0 deletions src/state/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export class Extension implements vscode.Disposable {
return this._gotoMenus as ReadonlyMap<string, Menu>;
}

private _activeModeDisplayPreference: string;
public get activeModeDisplayPreference() {
return this._activeModeDisplayPreference;
}

// State.
// ==========================================================================

Expand Down Expand Up @@ -120,6 +125,17 @@ export class Extension implements vscode.Disposable {
public constructor(public readonly commands: Commands) {
this.recorder = new Recorder(this);

// Configuration: mode display preference.
this._activeModeDisplayPreference = vscode.workspace.getConfiguration(extensionName)
.get<string>("activeModeDisplayTextTransform") ?? "as-is";
this.observePreference<string>(
".activeModeDisplayTextTransform",
(value, validator, inspect) => {
this._activeModeDisplayPreference = value;
},
true,
);

// Configuration: menus.
this.observePreference<Record<string, Menu>>(
".menus",
Expand Down