Skip to content
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

dont switch, if not insertMode; or switch but no save #4600

Closed
junfx opened this issue Feb 27, 2020 · 0 comments
Closed

dont switch, if not insertMode; or switch but no save #4600

junfx opened this issue Feb 27, 2020 · 0 comments

Comments

@junfx
Copy link

junfx commented Feb 27, 2020

imswitcher.js

switchInputMethod(prevMode, newMode) {
    return __awaiter(this, void 0, void 0, function* () {
        if (configuration_1.configuration.autoSwitchInputMethod.enable !== true) {
            return;
        }
        // when you exit from insert-like mode, save origin input method and set it to default
        let isPrevModeInsertLike = this.isInsertLikeMode(prevMode);
        let isNewModeInsertLike = this.isInsertLikeMode(newMode);
        if (isPrevModeInsertLike !== isNewModeInsertLike) {
            if (isNewModeInsertLike) {
                yield this.resumeIM();
            }
            else {
                yield this.switchToDefaultIM(); //**dont switch, if not insertMode; or switch but no save**
            }
        }
    });
}
// save origin input method and set input method to default
switchToDefaultIM() {
    return __awaiter(this, void 0, void 0, function* () {
        const obtainIMCmd = configuration_1.configuration.autoSwitchInputMethod.obtainIMCmd;
        try {
            const insertIMKey = yield this.execute(obtainIMCmd);
            if (insertIMKey !== undefined) {
                this.savedIMKey = insertIMKey.trim();
            }
        }
        catch (e) {
            this.logger.error(`Error switching to default IM. err=${e}`);
        }
        const defaultIMKey = configuration_1.configuration.autoSwitchInputMethod.defaultIM;
        if (defaultIMKey !== this.savedIMKey) {
            yield this.switchToIM(defaultIMKey);
        }
    });
}
@junfx junfx closed this as completed Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant